1

I have made a Radio Group with some Linear Layouts (having TextViews and RadioButtons in them) in it. I am able to select more than one options is this group which I don't want. How do I remove this thing?

     <RadioGroup
                       android:layout_width="match_parent"
                       android:layout_height="match_parent"
                       android:id="@+id/rg">

                       <LinearLayout
                           android:layout_width="match_parent"
                           android:layout_height="wrap_content"
                           android:id="@+id/ll1"
                           android:orientation="horizontal">

                           <RadioButton
                               android:layout_width="fill_parent"
                               android:layout_height="wrap_content"
                               android:layout_marginTop="10dp"
                               android:text="Option1"
                               android:textColor="#ffffff"
                               android:textSize="15sp"
                               android:layout_weight="0.5"
                               android:checked="false"
                               android:id="@+id/rbOption1" />

                           <TextView
                               android:layout_width="fill_parent"
                               android:layout_height="match_parent"
                               android:layout_weight="1.5"
                               android:id="@+id/oc1" />      

                       </LinearLayout>


                       <LinearLayout
                           android:layout_width="match_parent"
                           android:layout_height="wrap_content"
                           android:id="@+id/ll2"
                           android:orientation="horizontal">

                           <RadioButton
                               android:layout_width="fill_parent"
                               android:layout_height="fill_parent"
                               android:id="@+id/rbOption2"
                               android:layout_marginTop="10dp"
                               android:text="Option2"
                               android:textColor="#ffffff"
                               android:textSize="15sp"
                               android:layout_weight="0.5"/>

                           <TextView
                               android:layout_width="fill_parent"
                               android:layout_height="fill_parent"
                               android:layout_weight="1.5"
                               android:id="@+id/oc2" />



                       </LinearLayout>
</RadioGroup>
TheHardRock
  • 691
  • 7
  • 17

1 Answers1

0

Unfortunately, RadioGroup works only when RadioButtons are its direct children. You'll have to either implement the behavior yourself or redesign the layout.

SpaceBison
  • 2,525
  • 1
  • 21
  • 38