View gameView = new GameView(this);
replace the above line with the following line:
View gameView = new GameView(this).createView();
and now in game viewing mode with a button, etc.
public class GameView extends View {
private Activity _activity;
public GameView (Activity _activity) {
super(_activity);
this._activity = _activity;
}
public View createView(){
LinearLayout l = new LinearLayout(_activity);
l.setOrientation(LinearLayout.VERTICAL);
Button btn = new Button(_activity);
btn.setId(1);
btn.setText("btn"+(i+1));
l.addView(btn);
return l;
}
}
try this working code:
source
share