Checking Multiple Checkboxes In Android
CheckBox checkOne = (CheckBox) findViewById(R.id.checkOne); checkOne.setSelected(true); CheckBox checkTwo = (CheckBox) findViewById(R.id.checkTwo); checkTwo.setSelected(true); Ch
Solution 1:
If the parent LinearLayout contains only the checkboxes, you can do this:
//ll is the LinearLayout holding the childrenfor(int i = 0; i < ll.getChildCount(); i++) {
((CheckBox)ll.getChildAt(i)).setChecked(true);
}
if you have more views in the LinearLayout you could add a check like this:
for(inti=0; i < ll.getChildCount(); i++) {
Viewv= ll.getChildAt(i);
if(v instanceof CheckBox) {
((CheckBox)v).setChecked(true);
}
}
Post a Comment for "Checking Multiple Checkboxes In Android"