Control of CheckBox Android Studio

0

Good, I've been looking through different sites on the web and I can not find what I'm trying to do. It sounds simple but I do not know how it is done.

The question is this: In my application I have 5 checkBox with different themes (sport, history, biology ...) and a checkbox that is: All.

How can I make sure that when I check the "Everyone" checkbox, all others that are checked are removed?

    
asked by Pablheras 29.05.2017 в 09:49
source

1 answer

2

When you create the checkBox add them to a ArrayList in the following way:

//Iniciar un arraylist
ArrayList<CheckBox> checkArray = new ArrayList<CheckBox>();
// añade tus checkbox a la lista
checkArray.add(aCheckBox);

Then in your click event

for(i=0; i<checkArray.size(); i++)
{
    if (checkArray.get(i) != (CheckBox)v)  //  v es el parametro View que le pasas

       checkArray.get(i).setChecked(false);
}

If it does not work, let me know

    
answered by 29.05.2017 / 10:01
source