cannot populate view in multithreading environment in android
<p><strong>Error</strong>
05-12 11:56:45.793: ERROR/AndroidRuntime(505): Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.</p>

<p><strong>what i have done</strong></p>

<p>i have a list view inside my activity and i need to populate the listview by doing the following:
<code>mylistview.setAdapter(new CustomAdapter());</code></p>

<p>now there is already too much pressure on my UI thread so , thought of calling this method inside a AsynTask.</p>

<p><strong>Another problem</strong></p>

<p>there is a progress dialog that shows in my acitivity when the user clicks the button to populate the listview. when i put everything inside one thread the progress dialog does not show. i had asked a question on stackoverflow about why the progress dialog does not show and i had got a reply saying that i need to put all the extra tasks inside another thread.</p>

<p><strong>i have also read the <em>updating UI in android</em> given on android developer website:</strong>
but over there all we do is make a new runnable and post the runnable to the Handler of the UI thread so that when the UI is free, the runnable will be executed.
But how does the above solve my purpose? i mean the UI thread is still executing the instructions.</p>

<p>The only way i can take the load of the UI thread is if i make another thread and put all the work over there... but android does not allow this?</p>

<ul><li>what is wrong with my understanding(if there is anything wrong)? </li><li> How do i solve this problem</li></ul>

<p>thank you in advance.</p>
