开发者

runOnUIThread question

开发者 https://www.devze.com 2023-01-12 05:54 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消