Okay I'm trying to check if CheckBox1 and CheckBox2 was checked on Button-Click. I don't understand why it does not work this way:
public class MenuScreen extends ActionBarActivity {
private CheckBox kategorie1;
private CheckBox kategorie2;
public void onClick(View v) {
if (kategorie1.isChecked() == false && kategorie2.isChecked() == false) {
Toast.makeText(getBaseContext(), "STOP - You did not check any Checkboxes!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getBaseContext(), "GOOD - You're free to go!", Toast.LENGTH_SHORT).show();
Intent iinent= new Intent(MenuScreen.this,QuizScreen.class);
startActivity(iinent);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu_screen);
}}
keeps crashing my app with the error message:
Caused by: java.lang.NullPointerException
Hope someone can explain me why it does not work & show me how to do it properly. Thanks in advance!