[英]How to Radiogroup for a radio button in a Relative android layout
[英]RadioGroup with radiobuttons inside a relative android layout
我想创建一个如下所示的简单布局:
(o) Radio button A
(o) Radio button B [textedit]
[x] checkbox
为此,我创建了以下layout.xml:
<RadioGroup
android:layout_above="@+id/RadioButton_Count"
android:id="@+id/RadioGroup01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<RadioButton
android:layout_height="wrap_content"
android:id="@+id/RadioButton_A"
android:text="Play forever"
android:checked="true"
android:layout_width="fill_parent"
android:textSize="20sp">
</RadioButton>
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/RadioButton_B"
android:text="Count:"
android:textSize="20sp">
</RadioButton>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/EditText_NumCount"
android:inputType="number"
android:layout_toRightOf="@+id/RadioButton_B"
android:width="70sp" >
</EditText>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/CheckBox_StopCount"
android:text="Stop"
android:layout_below="@+id/RadioButton_B"
android:textSize="18sp">
</CheckBox>
</RelativeLayout>
</RadioGroup>
它看起来是正确的,但问题是radiobuttons之间没有连接,我的意思是它们可以在同一时刻同时开启。 我认为这是因为即使它们是悬挂在同一个第二个是在另一个布局内:\\有没有人有一些想法我怎么能做这种布局(主要是[textedit]恰到好处的RadioButton B),开始工作radiobuttons? 非常感谢你
你根本做不到。 我也试图做类似的事情而陷入困境。
“RadioButtons必须是RadioGroup的直接子女。” https://code.google.com/p/android/issues/detail?id=1214
首先要尝试的是在关闭最后一个RadioButton而不是结束后关闭你的RadioGroup。 更好的解决方案是使用RelativeLayout作为整体容器。 接下来添加您的RadioGroup和两个按钮并关闭该组。 相对于布局的其余部分添加其他元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.