Android – How to clear checkboxes when reset button is clicked

androidcheckbox

In my project I have a number of checkboxes in a linear layout. When running the project by default all checkboxes are unchecked and I need to check some checkboxes. Below the checkboxes there is a reset button. When the reset button is clicked all the checkboxes are unchecked. How do I do this? Please help.

Best Answer

Call this in onClick()of Reset button.

if (checkBox1.isChecked()) {
             checkBox1.setChecked(false);
         }
if (checkBox2.isChecked()) {
             checkBox2.setChecked(false);
         }

. . . and so on