0
Hello, I have a set of 8 checkBoxs. Does anyone know how I check if at least 1 of them was selected? Thank you
0
Hello, I have a set of 8 checkBoxs. Does anyone know how I check if at least 1 of them was selected? Thank you
1
If you want to try one-on-one:
boolean algumSelecionado = jcbx1.isSelected() || jcbx2.isSelected() || jcbx3.isSelected() || jcbx4.isSelected()
|| jcbx5.isSelected() || jcbx6.isSelected() || jcbx7.isSelected() || jcbx8.isSelected();
Or a more dynamic solution if Jcheckbox are inside a Jpanel:
boolean algumSelecionado = false;
for (Component c : jpnl.getComponents()) {
if (c instanceof JCheckBox && ((JCheckBox) c).isSelected()) {
algumSelecionado = true;
break;
}
}
1
CheckBox checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
checkBox1.isChecked();
Thank you. I added your answer to the colleague’s and gave everything wonderful.
Browser other questions tagged java android checkbox
You are not signed in. Login or sign up in order to post.
Simple and Brilliant! Thanks! I only changed . isSelected by . isChecked.
– Elaine Breda Schwaner
@Elainebredaschwaner is not
swing
? You have to see if the second option I put works then– Sorack
I don’t know what swing is. But it’s working, wonderful!
– Elaine Breda Schwaner