Android Cannot execute setListAdapter() user thread
<p>Sorry my last question was not well formated. So I am deleting the content and re framing my question.</p>

<p>I liked @ChrisBunney answer to my question with an example to process image in another thread.</p>

<p>Here is proper code below</p>

<pre><code>public class TestActivity extends ListActivity {

    int count =0;

    List&lt;String&gt; listString = null;

    String[] mString = null; 

      private RefreshHandler mRedrawHandler = new RefreshHandler();

      class RefreshHandler extends Handler {

            @Override

            public void handleMessage(Message msg) {

                TestActivity.this.updateUI();

            }



            public void sleep(long delayMillis) {

              this.removeMessages(0);

              sendMessageDelayed(obtainMessage(0), delayMillis);

            }

          };



          private void updateUI(){



              mRedrawHandler.sleep(1000);

              listString.add("Test "+count++);

              String[] mString = new String[listString.size()];

              int i = 0;

              for(String string : listString){
                  mString[i++]= string;
              }

              if(null != mString &amp;&amp; mString.length&gt;0)
              setListAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,mString ));


          }



          @Override 

          public void onCreate(Bundle icicle) { 

            super.onCreate(icicle); 

            setContentView(R.layout.main);

            listString = new LinkedList&lt;String&gt;();


            updateUI();


          } 



}
</code></pre>

<p>What I intend to do is call UI update from another thread.</p>

<p>This will be the modification to my above code file.</p>

<pre><code>private class HelperClass implements Runnable{

            public void run() {

                performSomeCalculation();

            }

            /*
             * This code will populate the list as it is executed.
             * As and when there is a new element in the list the UI is updated.
             */

            public void performSomeCalculation(){

                //update list String
                updateUI();
            }

/*




/*
           * 
           * The new update onCreate method calling another thread that populates the UI thread
           * 
           */

          @Override 

          public void onCreate(Bundle icicle) { 

            super.onCreate(icicle); 

            setContentView(R.layout.main);

            listString = new LinkedList&lt;String&gt;();


            //updateUI();

            Thread thread = new Thread(new HelperClass());
            thread.start();


          }
</code></pre>

<p>You can see in the above code I have created a HelperClass to perform some calculation , as and when there is ouput from the calculation thread it should update the UI thread.</p>

<p>I am working on it to make it work, if any one figures out plz update my post.</p>

<p>Thanks in advance.</p>
