To create each radio button option, create a RadioButton
in your layout. However, because radio buttons are mutually exclusive, you must group them together inside a RadioGroup
. By grouping them together, the system ensures that only one radio button can be selected at a time.
为了创建每个单选按钮选项,在你的 layout 中新建一个 RadioButton. 同时,因为单选按钮是互斥的,所以你必须将它们组合在一个 RadioGroup 中。通过将他们放在一组,系统可以确保一次只有一个单选按钮被选中。
Note: The RadioGroup
is a subclass of LinearLayout
that has a vertical orientation by default.
注意:RadioGroup 是垂直方向的 LinearLayout 的子类