简体   繁体   中英

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.

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. Eg, 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM