public class MainActivity extends Activity implements OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first_screen);
ImageButton x = (ImageButton) findViewById(R.id.imageButton1);
x.setOnClickListener(this);
}
public void onClick(View v) {
Intent intent = new Intent(
com.example.choiceisaseriousmatter.MainActivity.this,
Choice.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
// present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
This code is for switching to another Activity
when the imageButton
is clicked. But whenever I click on the button the program just crashes.