java - Assigning all check items into a variable -


is possible assign values checked items in single variable ? if radio button have code .getcheckedradiobuttonid(), checkboxes. here's xml layout checkboxes.

<checkbox                 android:id="@+id/cbfacilities"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="facility1"                 android:textcolor="#000000"                 android:textsize="20dp"                 android:textstyle="bold" />             <checkbox                 android:id="@+id/cbfacilities2"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="facility2"                 android:textcolor="#000000"                 android:textsize="20dp"                 android:textstyle="bold" />             <checkbox                 android:id="@+id/cbfacilities3"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="facility3"                 android:textcolor="#000000"                 android:textsize="20dp"                 android:textstyle="bold" /> 

meaning if check items , assign variable x. x = facility1 , facility2 , facility3 ?

string rg1 = "*";                                 string rg2 = "*";                                 string rg4 = "*";                                 string rg5 = "*";                                 thefilter[5] = "0";                                 if (cbregaffil.ischecked()) {                                     int reg = rgregaffil                                             .getcheckedradiobuttonid();                                     radiobutton rbtreg = (radiobutton) dia                                             .findviewbyid(reg);                                     rg1 = (string) rbtreg.gettext();                                  }                                 if (cbadmin.ischecked()) {                                     int adm = rgadmin                                             .getcheckedradiobuttonid();                                     radiobutton rbtadm = (radiobutton) dia                                             .findviewbyid(adm);                                     rg2 = (string) rbtadm.gettext();                                 }                                  if (cbambience.ischecked()) {                                     int amb = rgambience                                             .getcheckedradiobuttonid();                                     radiobutton rbtambience = (radiobutton) dia                                             .findviewbyid(amb);                                     rg4 = (string) rbtambience.gettext();                                 }                                 if (cbtuition.ischecked()) {                                     thefilter[5] = spin.getselecteditem()                                             .tostring();                                 }                                 if (cbspecialty.ischecked()) {                                     int spec = rgspecialty                                             .getcheckedradiobuttonid();                                     radiobutton rbtspec= (radiobutton) dia                                             .findviewbyid(spec);                                 //  rg5 = (string) rbtspec.gettext();                                  }                                 if (cbfacilities.ischecked()||cbfacilities2.ischecked()||cbfacilities3.ischecked()) {                 //**i want assign values checked here variable rg5**                                 }  

as notice im assigning radiobutton value variable, time in last part of program, value of cbfacilities1-3 if they're checked assign single variable holds string values.

well, think array of booleans hold answers.

could :

boolean[] checkboxanswers = new boolean[3]; checkboxanswers[0] = checkbox1.getchecked(); checkboxanswers[1] = checkbox2.getchecked(); checkboxanswers[2] = checkbox3.getchecked(); 

Comments