-1

I have crated 4 radiobutton in recyclerview but when i check one it checked but when i checked another one radiobutton then first one can not be unchecked

 holder.cb_votes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                for (int i = 0; i < pollItems.size(); i++) {
                    if (isChecked) {
                        holder.cb_votes.setChecked(true);

                    } else {
                        holder.cb_votes.setChecked(false);
                    }


                }
            }
        });

this is my xml

        <RadioGroup
            android:id="@+id/rg_cb_votes"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5">

            <RadioButton
                android:id="@+id/cb_votes"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="3dp"
                android:text="Yes"
                android:textSize="12dp" />

        </RadioGroup>
Mind Werx
  • 77
  • 12

1 Answers1

0

Radiobutton in wikipedia says:

A radio button or option button is a type of graphical user interface element that allows the user to choose only one of a predefined set of options.

You would have to just use checkboxes instead of radio button for allowing multiple options to be selected,else you are doing something which is inherently wrong in a UI be it mobile/web.

:-)

Aovin Mahmud
  • 204
  • 3
  • 18