Saturday, 15 June 2013

Can a background thread trigger a message handler on UI thread in android -


I have a thread that has been started in onCreate () and this thread contains some data Is it possible that ListView before the thread ends?

should be able to update, because the thread is not UI thread, it can not directly update the list view array adapter.

Is there any way? I was thinking that it is possible to trigger the handler from this thread, whose runabile is executed on the main UI thread.

Not sure if I fully understand your problem, but I believe that you want There are two ways to get it:

1- Instead of a thread, start a AsyncTask with onPostExecute () , which means that you can not find any UI-related can do. You can start asyncTask in onCreate (), and, once it is finished, it calls a method on your activity that:

  myAdapter.notifyDataSetChanged ();   

2-Use

No comments:

Post a Comment