【发布时间】:2016-03-28 10:59:07
【问题描述】:
我使用支持库中的 AppCompatRadioButtons 创建了一个相当简单的单选按钮组。然而,该小组似乎并没有在棒棒糖之前的版本上工作。我可以选择每个选项,但找不到任何关于它为什么这样做的迹象。
我正在使用运行 4.1 的模拟器进行测试。正如您在下面看到的,我可以选择多个选项。
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatRadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="W"/>
<android.support.v7.widget.AppCompatRadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Q"/>
<android.support.v7.widget.AppCompatRadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="B-Hum"/>
<android.support.v7.widget.AppCompatRadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="B-Sci"/>
<android.support.v7.widget.AppCompatRadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="B-Soc"/>
</RadioGroup>
在 Lollipop 和 Marshmallow 上进行测试获得了所需的结果。
【问题讨论】:
-
我已经在带有 jellybean 版本的 htc 设备中测试了相同的布局。它工作正常.. 一次只选择了一个 AppCompatRadioButton
标签: android radio-button radio-group