如何单选按钮组添加到单选按钮表内? [英] How to add a radio group to radio buttons inside of a table?

查看:138
本文介绍了如何单选按钮组添加到单选按钮表内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想用一个表来布置多个单选按钮,还包括他们在一个单选按钮组。我有以下的XML布局:

I have multiple radio buttons which I want to layout using a table but also include them in a single radio group. I have the following xml layout:

<RadioGroup android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"
      android:id="@+id/Group1">

    <TableLayout android:id="@+id/RadioButtons" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content">

        <TableRow>
            <RadioButton android:id="@+id/rad1" 
                android:text="RButton1" 
                android:layout_width="105px" 
                android:layout_height="wrap_content" 
                android:textSize="13px"></RadioButton>
            <RadioButton android:id="@+id/rad2" 
                android:text="RButton2" 
                android:layout_width="105px" 
                android:textSize="13px" 
                android:layout_height="wrap_content"></RadioButton>
            <RadioButton android:id="@+id/rad3" 
                android:text="RButton3" 
                android:layout_width="105px" 
                android:textSize="13px" 
                android:layout_height="wrap_content"></RadioButton>
        </TableRow>
      </TableLayout>
</RadioGroup>  

但遗憾的是表内的单选按钮,似乎忽略了一个事实,即他们是RadioGroup中标签内,因为这样你可以在时间选择多个单选按钮。我注意到,通过删除表,只是有单选按钮它工作得很好。我怎样才能解决这个?难道是简单的声明单选按钮组表,而不是外部的内部?感谢您的帮助。

But unfortunately the radio buttons inside the table seem to ignore the fact that they're inside of the RadioGroup tags and because of this you can select more than one radio button at the time. I noticed that by removing the table and just having the radio buttons it works just fine. How can I overcome this? Would it be as simple as declaring the radio group inside of the table instead of outside? Thanks for any help.

推荐答案

单选部件必须是 RadioGroup中的群体效应来工作。

Your RadioButton widgets must be immediate children of the RadioGroup for the group effect to work.

这篇关于如何单选按钮组添加到单选按钮表内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆