I already made multiple checkbox in dialog and want to get the checkbox value to textview in another activity, but i don't know the code, anyone can help?
Asked
Active
Viewed 716 times
3
-
1Post code of what you have already done. Break down your problem. 1) First learn to get value of checkbox. 2) Learn to pass value to other Activity 3) Learn to set textview – Sharjeel May 07 '15 at 03:04
-
You can achieve this by using Intents. http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android/7325248#7325248 – Ramon Guerrero May 07 '15 at 03:06
-
possible duplicate of [How to set Checkbox cheked value to textview in android?](http://stackoverflow.com/questions/19676690/how-to-set-checkbox-cheked-value-to-textview-in-android) – Sonia John Kavery May 08 '15 at 06:12
2 Answers
2
Try the following.
CheckBox cb=(CheckBox)findViewById(R.id.checkbox1);
TextView tv=(TextView)findViewById(R.id.textview1);
cb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(cb.isChecked()){
cb.setChecked(true);
tv.setText(cb.getText().toString());
}
}
});
If you want to use it in another activity,either you can save it in local storage like sharedpreference or to a global variable.

Sonia John Kavery
- 2,099
- 2
- 20
- 36
-
Was really looking for this. Could not figure out the getText() part. Thanks – Vlusion Nov 09 '20 at 21:59
0
first you get the value form the check box like ..
if (chk_Other_friOff.isChecked()) {
Global.newOther_fir = "1";
Log.e("Check box", "1st May ;;;" + Global.newOther_fir);
} else {
Global.newOther_fir = "0";
}
if (chk_Other_satOff.isChecked()) {
Global.newOther_sat = "1";
} else {
Global.newOther_sat = "0";
}
if (chk_Other_decOff.isChecked()) {
Global.newOther_dec = "1";
} else {
Global.newOther_dec = "0";
}
if (chk_Other_phone.isChecked()) {
Global.newOther_phone = "1";
} else {
Global.newOther_phone = "0";
}
Hear is Global is store a static value from conman class in my application. and is get to another Activity like
TextView tv;
tv.setText(Global.newOther_phone);
its very simple.
Thanks...

Hardik Parmar
- 712
- 2
- 13
- 28