runOnUIThread question

血红的双手。 提交于 2019-12-24 01:53:45

问题


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 together? 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


回答1:


You need to use the AsyncTask. See the docs for description and examples.



来源:https://stackoverflow.com/questions/3493667/runonuithread-question

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!