Try this..
Change your CheckBox
id in xml as check_1,check_2,check_3...check_17 like below for every 17
<CheckBox
android:id="@+id/check_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="check_1" />
and java
Declear as CheckBox[] checkboxs;
in global variable and initilize it like below
checkboxs = new CheckBox[17];
for (int i = 0; i < checkboxs.length; i++) {
checkboxs[i] = (CheckBox) findViewById(getIdByName("check_" + (i + 1)));
}
getIdByName method
public static int getIdByName(final String name) {
try {
final Field field = R.id.class.getDeclaredField(name);
field.setAccessible(true);
return field.getInt(null);
} catch (Exception ignore) {
return -1;
}
}
and you can check wheather check box is checked or not using below codes.
for (int i = 0; i < checkboxs.length; i++) {
if(checkboxs[i].isChecked()){
iCheck++;
}
}