I have a radiogroup with about 30 radiobuttons. I have looked around on stackoverflow and found a few posts about the accidental allowing of multiple radiobuttons to be checked. They were not in a radiogroup, or had problems with their id.
How can I purposefully allow 3 radiobutton to be selected at a time and implement a listener for those three selected.
I suspect I am doing something wrong. Is there another UI element out there that can help me get what I am looking for?
RadioGroups are designed to only allow 1 selection. It's confusing for users to have what is basically checkbox-like behaviour when they are using a RadioGroup.
If you really need to do this, you either need to use multiple RadioGroup objects, or use checkboxes instead.
Android Checkbox documentation is here: http://developer.android.com/reference/android/widget/CheckBox.html
You can attach listeners to the checkbox objects by using the following:
public void setOnCheckedChangeListener (CompoundButton.OnCheckedChangeListener listener)
来源:https://stackoverflow.com/questions/19306849/android-radiobutton-allow-more-than-one-to-be-check