Getting force close when i add view to other view when a thread is running

Posted by Praveena on Stack Overflow See other posts from Stack Overflow or by Praveena
Published on 2010-12-30T13:34:33Z Indexed on 2010/12/30 13:54 UTC
Read the original article Hit count: 302

Filed under:

Hi, I am getting the below error

12-30 05:40:40.484: ERROR/AndroidRuntime(413): Uncaught handler: thread Thread-10 exiting due to uncaught exception
12-30 05:40:40.494: ERROR/AndroidRuntime(413): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.ViewRoot.checkThread(ViewRoot.java:2629)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.ViewRoot.requestLayout(ViewRoot.java:545)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.View.requestLayout(View.java:7657)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.View.requestLayout(View.java:7657)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.View.requestLayout(View.java:7657)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.View.requestLayout(View.java:7657)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.View.requestLayout(View.java:7657)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.ViewGroup.addView(ViewGroup.java:1749)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.ViewGroup.addView(ViewGroup.java:1708)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at android.view.ViewGroup.addView(ViewGroup.java:1688)
12-30 05:40:40.494: ERROR/AndroidRuntime(413):     at com.wwwww.shout.presentationLayer.Shout$1.run(Shout.java:137)

and my code is

myProgressDialog = ProgressDialog.show(Shout.this,"","Loading...",true);

         new Thread() 
         {
         public void run()
         {
             String xml;



                 xml="<spGetUserMessages><SearchLocation></SearchLocation></spGetUserMessages>";
                 messages =parse.GetGetUserMessages(dataparsing.ILGetUserMessages(xml));
        myProgressDialog.dismiss();
((LinearLayout)findViewById(R.id.LinearlayoutMessage)).addView(iiii);


      }

    }.start();

at the time of adding views to the layout i am getting the above error.what is the wrong in this.Please give me some suggestions.Thanks in advance

© Stack Overflow or respective owner

Related posts about android