xml – 如何将广播组添加到表格内的单选按钮?

前端之家收集整理的这篇文章主要介绍了xml – 如何将广播组添加到表格内的单选按钮?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有多个单选按钮,我想使用表布局,但也包括在一个单一的广播组.我有以下xml布局:
  1. <RadioGroup android:layout_width="fill_parent"
  2. android:layout_height="wrap_content"
  3. android:orientation="vertical"
  4. android:id="@+id/Group1">
  5.  
  6. <TableLayout android:id="@+id/RadioButtons"
  7. android:layout_width="wrap_content"
  8. android:layout_height="wrap_content">
  9.  
  10. <TableRow>
  11. <RadioButton android:id="@+id/rad1"
  12. android:text="RButton1"
  13. android:layout_width="105px"
  14. android:layout_height="wrap_content"
  15. android:textSize="13px"></RadioButton>
  16. <RadioButton android:id="@+id/rad2"
  17. android:text="RButton2"
  18. android:layout_width="105px"
  19. android:textSize="13px"
  20. android:layout_height="wrap_content"></RadioButton>
  21. <RadioButton android:id="@+id/rad3"
  22. android:text="RButton3"
  23. android:layout_width="105px"
  24. android:textSize="13px"
  25. android:layout_height="wrap_content"></RadioButton>
  26. </TableRow>
  27. </TableLayout>
  28. </RadioGroup>

但不幸的是,桌子内的单选按钮似乎忽略了他们在RadioGroup标签内的事实,因此,您可以选择多个单选按钮.我注意到,通过删除桌子,只是有单选按钮,它的工作正常.我该如何克服呢?是否简单地将表格内的无线电组声明为外部?感谢任何帮助.

RadioButton小部件必须是RadioGroup的直接子项才能使组效果工作.

猜你在找的XML相关文章