I'm create a download manager with listview and it will display the current downloaded by progressbar. May I know how can i update the progressbar?
for example. i have 3 class.
"main.class" = is a listview.
"mAdapter.class" = is extends ArrayAdapter.
"mThread.class" = implements Runnable to start the download.
I have google, and found to update the listview, or redrawing the UI should use runOnUIThread
. but how can i combine those 3 class togethe开发者_如何学Cr? I have try
mThread.start(){
main.runOnUIThread(updated);
}
private updated = new Runnable(){
mAdapter.progressbar.setProgress(downloaded);
}
this 2 method i was put in "mThread.class". but it doesn't work. May I know what i was my misstake?
P/S:I'm sorry about my ugly code and bad english. Hope you guys understand what I'm talking about. Thanks
You need to use the AsyncTask. See the docs for description and examples.
精彩评论