I have created an menu page for my app that has 4 buttons each with a different function. Before adding in this menu page my code looked like this in my activity_main.xml
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//sets full screen
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set no title
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.setContentView(new GameSurface(this));
Now I have this menu page with the 4 buttons which I have assigned in the MainActivity class to a variable in the following manner (only one shown for example purposes).
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button newGameBtn = findViewById(R.id.new_game_btn);
I then created the onclick listeners like so
newGameBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
I have tried different methods within this to make the GameSurface class load (the class which before loaded the game) , it extends SurfaceView and implements SurfaceHolder.Callback. Any suggestions would be much appreciated.