I am getting an exception here when I try to bring another view to the front. It happens in the last method of my BoardView class where it says if(lives == 0). Can anybody see w
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();
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.