superuser
superuser

Reputation: 731

Android RadioButton allow more than one to be check

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.

https://stackoverflow.com/questions/8265034/android-radiogroup-checks-more-than-one-radiobuttonhttps://stackoverflow.com/questions/17157705/radiogroup-allows-multiple-radiobuttons-to-be-selected

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?

Upvotes: 0

Views: 5104

Answers (1)

Karl
Karl

Reputation: 3464

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)

Upvotes: 1

Related Questions