I found it there is prablem when i changed it in another thread. it
always said me. how to changed it without error message.

06-30 08:35:03.102: ERROR/AndroidRuntime(627): android.view.ViewRoot
$CalledFromWrongThreadException: Only the original thread that created
a view hierarchy can touch its views.
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.ViewRoot.checkThread(ViewRoot.java:2802)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.ViewRoot.invalidateChild(ViewRoot.java:607)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.ViewRoot.invalidateChildInParent(ViewRoot.java:633)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.ViewGroup.invalidateChild(ViewGroup.java:2505)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.View.invalidate(View.java:5139)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.View.onFocusChanged(View.java:2664)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.View.clearFocusForRemoval(View.java:2577)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:2289)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.view.ViewGroup.removeAllViews(ViewGroup.java:2254)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:
215)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:
207)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
android.app.Activity.setContentView(Activity.java:1658)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
Rhythmi.android.Rhythmi.OnViewChange(Rhythmi.java:185)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at
Rhythmi.android.Rhythmi$UpdateTask.run(Rhythmi.java:76)
06-30 08:35:03.102: ERROR/AndroidRuntime(627):     at java.util.Timer
$TimerImpl.run(Timer.java:289)

The construction what i did is this

MainActivity extends Activity
{


   /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);

        // Set game layout

        __StaticView = new CircleList(this);

        __GLView = new OGLSurfaceView(this);
        setContentView(__GLView);



        __GLView.setFocusable(true);
        __GLView.setFocusableInTouchMode(true);


        __currActivity   = this;
        __IsGLView     = true;

    }


/**
         * Canvas update task
         *
         * @author vsilva
         *
         */
        private class UpdateTask extends TimerTask {

                @Override
                public void run()
                {
                        System.out.println("Hello");

                        if(OpenglRenderer.__giNativeState == 8)
                        {
                                if(__IsGLView == true)
                                {
                                        OnViewChange();
                                }
                        }
                        else
                        {
                                if(__IsGLView == false)
                                {
                                        OnViewChange();
                                }
                        }


                }
        }


    public void OnViewChange()
    {
        if(__IsGLView)
        {


                __currActivity.setContentView(__StaticView);

                __IsGLView = false;
        }
        else
        {


                __currActivity.setContentView(__GLView);

                __IsGLView = true;
        }

                System.out.println("View is successfully changed.");

    }


}




following information, i have tried to changed view in thread. but it
always gave me the message. so what is the way to do? please someone
tell me what's idea is here..?

On 6월30일, 오후3시37분, choi <[email protected]> wrote:
> Hello,
> I'm spending hard time for switching GLSurfaceView and regular view.
> for doing it, i just tried as sample code provided.
>
> if(__IsGLView)
> {
>         System.out.println("__IsGLView is true");
>         __GLView.setFocusable(false);
>         __GLView.setFocusableInTouchMode(false);
>
>         __currActivity.setContentView(__StaticView);
>
>         __StaticView.setFocusable(true);
>         __StaticView.setFocusableInTouchMode(true);
>
>         __IsGLView = false;
>
> }
>
> else
> {
>         System.out.println("__IsGLView is false");
>         __StaticView.setFocusable(false);
>         __StaticView.setFocusableInTouchMode(false);
>
>         __currActivity.setContentView(__GLView);
>
>         __GLView.setFocusable(true);
>         __GLView.setFocusableInTouchMode(true);
>
>         __IsGLView = true;
>
> }
>
> Whenever i tried, it just gave us error message. i don't know how to
> change it smoothly between them. If someone know about it. please
> share it us. it really hard for me.
>
> Regards.

-- 
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