0

I am having radiogroup with 4 radio button. the problem is all radio button are getting selected. Cant understand what is the problem, My layout is below:

          <RadioGroup
                android:id="@+id/status_yesno_radiogroup"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:weightSum="100">

                <RadioButton
                    android:id="@+id/status_public"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:checked="true"
                    android:text="Public"
                    android:textStyle="bold"
                    android:layout_weight="50"/>

                <RadioButton
                    android:id="@+id/status_private"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Private"
                    android:textStyle="bold"
                    android:layout_weight="50"/>
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:weightSum="100">

                    <RadioButton
                        android:id="@+id/status_listed"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Listed"
                        android:textStyle="bold"
                        android:layout_weight="50"/>

                    <RadioButton
                        android:id="@+id/status_opc"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="OPC     "
                        android:textStyle="bold"
                        android:layout_weight="50"/>
                </LinearLayout>
            </RadioGroup>

when i am clicking radio buttons. all radio buttons are getting checked see screenshot

Screenshot is attched.Screenshot

Zaki Pathan
  • 1,762
  • 1
  • 13
  • 26
  • `RadioButton`s must be direct children of the `RadioGroup` for the default, single-selection behavior to work. – Mike M. Jan 21 '17 at 10:06
  • So what can i do to display this type of layout? – Zaki Pathan Jan 21 '17 at 10:07
  • hello Mike M., is there any solution? – Zaki Pathan Jan 21 '17 at 10:16
  • Check the accepted answer on the linked duplicate. You'll have to change your layout slightly. You'll need two `RadioGroup`s inside of a `LinearLayout`, instead of the two `LinearLayout`s in the `RadioGroup`. Keep in mind that `RadioGroup` is a `LinearLayout`, so you can set the `orientation` as needed on those, too. – Mike M. Jan 21 '17 at 10:17
  • thanks Mike M. I think its works but need to implement and check – Zaki Pathan Jan 21 '17 at 10:20

0 Answers0