I got a program that has 50+ checkboxes on one page.
And I need to check which boxes are selected.
I know I can do somehting like this:
CheckBox cb1 = (CheckBox) findViewById(R.id.checkBox1);
CheckBox cb2 = (CheckBox) findViewById(R.id.checkBox2);
if (cb1.isChecked){
//get Checkbox name
}
if (cb2.isChecked){
//get Checkbox name
}
But if I have to do this with more then 50 checkboxes, that would take some time.
Is their a faster way to check which on is selected? Something like:
int i;
for (i = 0; i<checkBox.length; i++){
CheckBox cb+i = (CheckBox) findViewById (R.id.checkBox+i);
if (cb+i.isChecked){
//get Checkbox name
}
}
Maybe also good to say: you can select more then 1 checkbox.
I hope you know what I mean.
Thanks already,
Bigflow
Another workaround may be:
Suppose you have added
CheckBoxinLinearLayoutand you can get theLinearLayoutreference in Java and get the child Views like this: