Hi, I'm having a few difficulties working out how to iterate a particular statement in my Android application. The app can contain a variable number of CheckBox's which I want to test if each is checked, and if so, gather the text that is included with the CheckBox. Here is an example where hat is a ListArray and cb1 and cb2 are checkbox:

if (cb1.isChecked()){
hat.add((String) cb1.getText());
}
if (cb2.isChecked()){
hat.add((String) cb2.getText());
}

What I want to be able to do is iterate this so that it tests and runs the hat.add() for each individual CheckBox by counting the number of CheckBox's in the app. Hopefully enough is included here to portray my problem. Any help is appreciated.

Kind Regards,
FiferSheep