I did it :

                // Create a thread to change the view
                final Grid f_grid = grid;
                Runnable mainThreadRunnable = new Runnable() {
                        public void run() {
                                m_activity.setContentView(f_grid);
                        }
        };
        // Run the thread
                m_activity.runOnUiThread(mainThreadRunnable);

It works great, is it a correct way ?

On 21 jan, 15:23, for android <[email protected]> wrote:
> you are probably calling from a seperate thread..after thread has done its
> wrk...use the handler and change the view..
>
> On Wed, Jan 21, 2009 at 7:49 PM, Nico <[email protected]> wrote:
>
> > Hi,
> > I need to replace the current View (set by the activity.setContentView
> > method) by an other.
> > When I call activity.setContentView two times, I get this exception :
> > 01-21 14:13:54.747: WARN/System.err(1156): android.view.ViewRoot
> > $CalledFromWrongThreadException: Only the original thread that created
> > a view hierarchy can touch its views.
> > 01-21 14:13:54.757: WARN/System.err(1156):     at
> > android.view.ViewRoot.checkThread(ViewRoot.java:1849)
> > 01-21 14:13:54.757: WARN/System.err(1156):     at
> > android.view.ViewRoot.requestLayout(ViewRoot.java:455)
> > 01-21 14:13:54.767: WARN/System.err(1156):     at
> > android.view.View.requestLayout(View.java:6575)
> > 01-21 14:13:54.767: WARN/System.err(1156):     at
> > android.view.View.requestLayout(View.java:6575)
> > 01-21 14:13:54.777: WARN/System.err(1156):     at
> > android.view.View.requestLayout(View.java:6575)
> > 01-21 14:13:54.777: WARN/System.err(1156):     at
> > android.view.ViewGroup.removeAllViews(ViewGroup.java:2033)
> > What is problem ?
> > Thx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to