为了账号安全,请及时绑定邮箱和手机立即绑定

如何分组3x3网格的单选按钮?

如何分组3x3网格的单选按钮?

蛊毒传说 2019-09-02 16:06:48
正如标题所描述的那样,我正在尝试将一个3x3单选按钮网格组合成一个单一的无线电组。在之前的一个问题中,我了解到,对于与单个组相对应的单选按钮,他们必须是他们将对应的无线电组的直接子项。当我试图在一个广播组中封装整个表格布局(在表行中使用单选按钮)时,我学到了很多。跑进那堵墙,我尝试了以下几点:<TableLayout android:id="@+id/table_radButtons"         android:layout_width="wrap_content"         android:layout_height="wrap_content"        android:layout_below="@+id/title_radGroup_buffer">        <TableRow>            <RadioGroup android:layout_width="fill_parent"                 android:layout_height="wrap_content"                 android:orientation="horizontal"                android:id="@+id/radGroup1">                  <RadioButton android:id="@+id/rad1"                     android:text="Button1"                     android:layout_width="105px"                     android:layout_height="wrap_content"                     android:textSize="13px"></RadioButton>                <RadioButton android:id="@+id/rad2"                     android:text="Button2"                     android:layout_width="105px"                     android:textSize="13px"                     android:layout_height="wrap_content"></RadioButton>                <RadioButton android:id="@+id/rad3"                     android:text="Button3"                     android:layout_width="105px"                     android:textSize="13px"                     android:layout_height="wrap_content"></RadioButton>            </RadioGroup>        </TableRow>        <TableRow>            <RadioGroup android:layout_width="fill_parent"                 android:layout_height="wrap_content"                 android:orientation="horizontal"                android:id="@+id/radGroup1">                  <!-- snippet -->        </TableRow>        <!-- snippet ---></TableLayout>显然我第一次没有学习,因为我再次遇到了一堵墙。我希望不同表行中的单选按钮会注意到它们是同一个无线电组的一部分(给每个组提供相同的ID),但这不起作用。有没有什么方法可以将所有这些按钮分组到一个单独的无线电组中并仍然保持我的3x3结构(每行3行,3个单选按钮)?
查看完整描述

3 回答

?
慕村9548890

TA贡献1884条经验 获得超4个赞

您唯一的选择是获取源代码RadioGroup并尝试在一个TableLayout或多个东西中复制其功能。RadioButtons否则无法创建3x3网格。幸运的是,RadioButton班级不知道RadioGroup- 所有的互斥逻辑都在RadioGroup。因此,应该可以创建一个RadioGrid或者某个东西......但这将是一项非常多的工作。


查看完整回答
反对 回复 2019-09-02
  • 3 回答
  • 0 关注
  • 395 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信