【问题标题】:Mutiple options get selected in RadioGroup在 RadioGroup 中选择了多个选项
【发布时间】:2016-06-28 19:00:57
【问题描述】:

我已经创建了一个带有一些线性布局(其中包含 TextViews 和 RadioButtons)的 Radio Group。我可以选择多个选项是我不想要的这个组。如何删除这个东西?

     <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>

【问题讨论】:

  • this 为你解决了吗?

标签: android xml radio-group


【解决方案1】:

不幸的是,RadioGroup 仅在 RadioButtons 是其直接子级时才有效。您必须自己实现行为或重新设计布局。

【讨论】:

    猜你喜欢
    • 2023-03-10
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多