In my main activity, I have 6 checkboxes for selecting which parts of a test the person will want to take. I've looked at a bunch of pages trying to figure out what to do, but I couldn't gain a clear understanding of what I was supposed to do.
Let's say, in my main activity, I have the checkboxes:
CheckBox grade1 = (CheckBox)findViewById(R.id.grade1);
CheckBox grade2 = (CheckBox)findViewById(R.id.grade2);
CheckBox grade3 = (CheckBox)findViewById(R.id.grade3);
CheckBox grade4 = (CheckBox)findViewById(R.id.grade4);
CheckBox grade5 = (CheckBox)findViewById(R.id.grade5);
CheckBox grade6 = (CheckBox)findViewById(R.id.grade6);
And if they're checked, I want to pass them to my next activity using this onClick (with whatever code needs to be added to make it work):
private void setupMessageButton() {
Button messageButton = (Button) findViewById(R.id.main_button);
messageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Test.class));
}
});
}
Then in my new activity, I have if statements which are currently written this way:
if (grade1.isChecked()){
// Do stuff
}
I'm looking for the simplest way to do this. TL:DR - If a checkbox is checked in one activity, how can I use that status to do something in another activity with an if statement?
Aucun commentaire:
Enregistrer un commentaire