Reputation: 2760
I know that you cant uncheck a radiobutton in android by pressing it again. But you can uncheck all the other radioButtons if one radiobutton is checked.
The question is how can I know that one radiobutton was clicked in a radiobutton group..?
could someone also give me a link to a short snippet of how to to reset all the radiobuttons in a group while one radio button was selected?!?!
Upvotes: 0
Views: 2311
Reputation: 10533
Take a look at the official guide (scroll down to Radio Buttons).
It reads: It's important that the RadioButtons are grouped together by the RadioGroup element so that no more than one can be selected at a time. This logic is automatically handled by the Android system. When one RadioButton within a group is selected, all others are automatically deselected.
It also provides some code snippets for listening to and handling click events.
Upvotes: 1
Reputation: 3619
radioButtonGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup,
int radioButtonID) {
switch(radioButtonID) {
case R.id.radioButton1:
//radio 1 clicked
break;
case R.id.radioButton2:
//radio 2 clicked
break;
case R.id.radioButton3:
//radio 3 clicked
break;
}
}
});
I hope it wil help u..
Upvotes: 1