且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使主线程等待,当我不知道异步任务何时才能完成工作.?

更新时间:2023-02-09 18:10:09

如果您使用过AsyncTask,请在doInBackground()中进行xml提取,并更新onPostExecute()中listview的所有UI元素,然后在主UI线程,并自动在doInBackground()之后.这样,您不必显式使UI线程等待

If you have used AsyncTask, then do the xml fetch in doInBackground() and update all your UI elements of the listview inside the onPostExecute(), this runs on the main UI thread and is automatically after doInBackground(). This way you dont have to explicitly make the UI thread wait