Android adapter list not working inside thread() for ProgressDialog
<p>Below is my code that is not working and i dont understand why it says <strong><em>"Only the original thread that created a view hierarchy can touch its views."</em></strong> when i want to set the adapter for my listview inside LoadValues() method.. <strong><em>"listView.setAdapter(adapter)"</em></strong> </p>

<pre><code>public class ProgressDialogActivity extends Activity {

    private ProgressDialog progressDialog;  
    private ListView listView;
    private ArrayList&lt;String&gt; lstValores;
    private Handler progressBarHandler = new Handler();

    private int mProgressStatus, mProgressTotal;    

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);              

        lstValores = new ArrayList&lt;String&gt;();
        listView = (ListView) findViewById(R.id.listView1);

        this.LoadValues();

    }//onCreate   


    public void LoadValues(){

        progressDialog = new ProgressDialog(ProgressDialogActivity.this);
        progressDialog.setTitle("Aguarde..");
        progressDialog.setMessage("Cargando lista..");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setProgress(0);
        progressDialog.show();

        new Thread(new Runnable() {         
            public void run() {         

                mProgressTotal = (int) 1000;

                try {
                    for (int i = 0; i &lt; mProgressTotal; i++) {

                        lstValores.add("valor " + i);

                        mProgressStatus = (int) ((i * 100) / mProgressTotal);

                        progressBarHandler.post(new Runnable() {                        
                            public void run() {
                                progressDialog.setProgress(mProgressStatus);
                                }
                            });                 
                        }// end for      

                        ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(ProgressDialogActivity.this, 
                                                                                R.layout.textviewlist_layout, 
                                                                                lstValores);
                        listView.setAdapter(adapter);                       
                        progressDialog.dismiss();

                } catch (Exception e) {
                    e.printStackTrace();                
                }

            }// end run
        }).start();// end Thread        
    }// end LoadValues


} // Activity
</code></pre>
