android单选按钮
Radio Button in android apps are very common. In this tutorial we’ll implement android radio button widget in our application. Radio Buttons are used when we need to select only one item from a list of presented items.
android应用中的单选按钮非常常见。 在本教程中,我们将在应用程序中实现android单选按钮小部件。 当我们只需要从显示的项目列表中选择一个项目时,使用单选按钮。
Android单选按钮 ()
A radio button consists of two states – checked and unchecked. Clicking an unchecked button changes its state to “checked” state and “unchecked” for the previously selected radio button. To toggle a checked state to unchecked state, we need to chose another item. Clicking a checked state button doesn’t do any good. A RadioGroup
is a set of radio buttons. Radio Buttons that have different parent ViewGroup can’t be termed as a RadioGroup.
单选按钮包含两个状态-选中和未选中。 单击未选中的按钮,将其状态更改为“选中”状态,将先前选择的单选按钮的状态更改为“未选中”。 要将选中状态切换为未选中状态,我们需要选择另一项。 单击选中的状态按钮没有任何好处。 RadioGroup
是一组单选按钮。 具有不同父ViewGroup的单选按钮不能称为RadioGroup。
Android单选按钮属性 ()
Some of the attributes of android radio button and radio group are listed below:
下面列出了android单选按钮和单选组的一些属性:
android:orientation
: This property on the Radio group defines the orientation to position its child view consisting of Radio Buttons. It can be either horizontal or verticalandroid:orientation
:单选按钮组上的此属性定义用于定位其子视图(由单选按钮组成)的方向。 它可以是水平或垂直的check(id)
: This sets the selection to the radio button whose identifier is passed in parameter. -1 is used as the selection identifier to clear the sele