I want a button to open an activity class that sets a layout xml file. Everything is in order but the button doesn't work without the @Override method. With the @Override method I get this error:
The method onCreate1(Bundle) of type MainActivity must override or implement a supertype method.
Button button;
@Override
public void onCreate1(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from activity_main.xml
setContentView(R.layout.activity_main);
// Locate the button in activity_main.xml
button = (Button) findViewById(R.id.MyButton);
// Capture button clicks
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// Start NewActivity.class
Intent myIntent = new Intent(MainActivity.this,
NewActivity.class);
startActivity(myIntent);
}
});
}
The reason is I already have an @Override annotation for another method.
What I have tried:
Reading the tutorial on activities, multiple activities, and passing data between activities.
Solving the problem by editing the android manifest.
Creating a separate launch intent for the activity.