call setListAdapter() from inside a thread

Posted by Mats Hofman on Stack Overflow See other posts from Stack Overflow or by Mats Hofman
Published on 2010-06-15T18:31:30Z Indexed on 2010/06/15 18:42 UTC
Read the original article Hit count: 518

Filed under:
|
|

Hi,

I have a problem with my ListActivity, i use a thread to show a ProgressDialog where get a list of all installed applications. I turn it into a list adapter and than i want to set the listadapter of the activity but i can't do that from the thread.

I get the following error: ERROR/AndroidRuntime(14429): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

new Thread() {
    public void run() {
          showList(); // the method where i get all the apps and have the setListAdapter(); method
          progressDialog.dismiss();
    }
}.start();

How do I get it so I can use the setListAdapter from inside my thread

© Stack Overflow or respective owner

Related posts about android

Related posts about listactivity