I have added a TextView
to a RelativeLayout
that I already added a SurfaceView
to. I can get the TextView
to display text over my SurfaceView
.
rl = new RelativeLayout(this);
tv = new TextView(this);
tv.setText(Integer.toString(GameScreen.score));
tv.setTextSize(50);
tv.setPadding(390, 50, 0, 0);
tv.setTextColor(Color.BLACK);
rl.addView(renderView);
rl.addView(tv);
setContentView(rl);
Then in my GameScreen class's update method i put:
game.getTextView().setText(Integer.toString(score));
And it gives me the error:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
What can I do to get around this ?