3

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?

AADProgramming
  • 6,077
  • 11
  • 38
  • 58
Anonymous
  • 37
  • 3
  • 1
    Post 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 Answers2

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
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