scibor scibor - 1 year ago 133
Android Question

Two checkboxes, can only select one

I'm working on a login screen where basically you can selected whether you want a 4 digit PIN access or a swipe method security; the way I want this to look is that there are two checkboxes in the layout, initially they're both unchecked. When you select one, it gets checked, but then if you try to select the other one, it unchecks the first one automatically. I have two checkboxes defined in the layout, but I'm a little confused by what I'd have to reference to force the unchecking.

public void onCheckBoxClicked(View view){
boolean checked = ((CheckBox)view).isChecked();


Basically, I know that something has to go into that if{} statement that unchecks setupCheckBox2 automatically, but I'm just unsure of what has to be made false. Any help appreciated!

Also, I realize this is kind of a one line answer, if anyone has any good references to checkboxes in Android, I wouldn't mind reading up on that either, I'm kind of new to this stuff.

Answer Source
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download