Immediate Disclaimer: I am not a programmer, I've been dumped with this as part of a group project, so apologies if the code is shabby.
I've got a main activity as the start-up page with several buttons that should open different activities, three of these buttons work perfectly with opening up their specific activities (Main2Activity, MOT and Garage), but the others, with the same structure being used, just close the app instead of opening the next screen.
public void defineButtons() {
findViewById(R.id.mot_button).setOnClickListener(buttonClickListener);
findViewById(R.id.enter_button).setOnClickListener(buttonClickListener);
findViewById(R.id.garage_button).setOnClickListener(buttonClickListener);
findViewById(R.id.profile_button).setOnClickListener(buttonClickListener);
findViewById(R.id.contact_button).setOnClickListener(buttonClickListener);
findViewById(R.id.settings_button).setOnClickListener(buttonClickListener);
}
private View.OnClickListener buttonClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.mot_button:
Intent intent = new Intent(MainActivity.this, MOT.class);
startActivity(intent);
break;
case R.id.garage_button:
Intent x = new Intent(MainActivity.this, garage.class);
startActivity(x);
break;
case R.id.profile_button:
Intent a = new Intent(MainActivity.this, Profile.class);
startActivity(a);
break;
case R.id.contact_button:
Intent b = new Intent(MainActivity.this, Contact.class);
startActivity(b);
break;
case R.id.settings_button:
Intent c = new Intent(MainActivity.this, Activity_Settings.class);
startActivity(c);
break;
case R.id.enter_button:
reg_input=findViewById(R.id.reg_input);
Intent i = new Intent(MainActivity.this, Main2Activity.class);
regNo = reg_input.getText().toString();
i.putExtra("Value", regNo);
startActivity(i);
finish();
break;
This is the relevant code for it, let me know if you want to see anything else. I'm probably being really stupid, but I'd appreciate the help.