i have created check boxes using loop and i want to validate it. Like i just want to check only 3 from the check boxes , when i press on the 4th one it should show an alert and uncheck it.

And i am able to get the alert when i press the 4the one but it is not unchecking.
anybody faced such issue and how did you solve it ?
You will also need a global variable call numChecked:
You will also need to add a .addView(ch) in the loop’s end to add the CheckBoxes to your layout.