简体   繁体   English

RadioGroup与相对android布局内的radiobuttons

[英]RadioGroup with radiobuttons inside a relative android layout

I want to create a simple layout like the following: 我想创建一个如下所示的简单布局:

(o) Radio button A
(o) Radio button B [textedit]
    [x] checkbox

For that I've created the following layout.xml: 为此,我创建了以下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>

It looks right, but the problem is that the radiobuttons doesn't connect between each other, i mean that they can be both on in the same moment. 它看起来是正确的,但问题是radiobuttons之间没有连接,我的意思是它们可以在同一时刻同时开启。 I think it's because even if they're hanging from the same the second one is inside another layout :\\ Does anyone have some idea how could I make this kind of layout (Mainly the [textedit] just right the RadioButton B), getting working also the radiobuttons? 我认为这是因为即使它们是悬挂在同一个第二个是在另一个布局内:\\有没有人有一些想法我怎么能做这种布局(主要是[textedit]恰到好处的RadioButton B),开始工作radiobuttons? Thank you very much 非常感谢你

You simply can't do it. 你根本做不到。 I was also trying to do something similar and got stuck. 我也试图做类似的事情而陷入困境。

"RadioButtons have to be direct children of RadioGroup." “RadioButtons必须是RadioGroup的直接子女。” https://code.google.com/p/android/issues/detail?id=1214 https://code.google.com/p/android/issues/detail?id=1214

The first thing to try is to close your RadioGroup right after you close the last RadioButton instead of at the end. 首先要尝试的是在关闭最后一个RadioButton而不是结束后关闭你的RadioGroup。 A better solution is to use a RelativeLayout as the overall container. 更好的解决方案是使用RelativeLayout作为整体容器。 Next add your RadioGroup and both buttons and close the group. 接下来添加您的RadioGroup和两个按钮并关闭该组。 Add the other elements relative to the rest of the layout. 相对于布局的其余部分添加其他元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在相对Android布局中对单选按钮进行Radiogroup - How to Radiogroup for a radio button in a Relative android layout 获取 Android 中 RadioGroup 中的 RadioButtons 数组 - Get the array of RadioButtons in a RadioGroup in Android Android:RadioGroup的RadioButtons之间的EditText - Android: EditText in between RadioButtons of a RadioGroup Android radiogroup,radiobuttons之间的分隔线 - Android radiogroup, divider between radiobuttons 从膨胀的列表视图布局中将RadioButton添加到RadioGroup中 - Adding RadioButtons from inflated listview layout into RadioGroup 在RadioGroup中使用RelativeLayout可以使RadioButtons不排他 - Using RelativeLayout inside RadioGroup make RadioButtons not exclusive 如何减少Android中单选按钮中单选按钮之间的空间? - How to reduce space between radiobuttons in a radiogroup in android? Android - RadioButtons在RadioGroup中肆虐 - 格式化问题 - Android - RadioButtons squishing up in RadioGroup - formatting issues 从Android中的radiogroup中删除动态创建的radiobuttons - remove dynamicallly created radiobuttons from a radiogroup in Android 在Android中的RadioGroup中对齐RadioButton(由代码创建) - Align RadioButtons in RadioGroup (created by code) in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM