user3267319
user3267319

Reputation: 118

Transfer Data to a different Activity

When I check a CheckBox I want the checkbox to be transfered to a differnet Activity and deleted in the previuos Activity.

Please Help me or lead me in the right direction.

Upvotes: 0

Views: 34

Answers (1)

Karim Varela
Karim Varela

Reputation: 7652

I believe what you want to happen is that the value from the CheckBox is sent to the next Activity. To do this, send the value as an extra on the intent. E.g., in ActivityA:

final CheckBox checkBoxA = (CheckBox) findViewById(R.id.checkbox_id_A);
...
boolean value = checkBoxA.isChecked();
....
Intent intent - new Intent(this, ActivityB.class);
intent.putExtra("checkbox_value", value);

In ActivityB's onCreate() method:

final CheckBox checkBoxB = (CheckBox) findViewById(R.id.checkbox_id_B);
boolean value = getIntent().getBooleanExtra("checkbox_value", false);
checkBoxB.setChecked(value);

Upvotes: 2

Related Questions