Called From Wrong Thread Exception

戏子无情 提交于 2019-12-02 09:32:04

You need to run the bring to front on the right thread. Try this:

final View v = ((BoardView) getParent()).findViewById(1);
v.post(new Runnable(){ public void run(){ v.bringToFront(); } });

See if that works.

You must update the View using the UI thread (not the SurfaceView thread). If you would like to make some View change from within the SurfaceView thread you must create a new RunOnUiThread which performs the View updating.

// From within SurfaceView thread
new Thread() {
    public void run() {
        activity.runOnUiThread(new Runnable() {     
            @Override
            public void run() {
                // Update view here
            }
        });
    }
}.start();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!