gpt4 book ai didi

java - 只有一个单选按钮

转载 作者:行者123 更新时间:2023-12-02 00:10:20 26 4
gpt4 key购买 nike

我在一个示例中读到,如果您使用多个单选按钮,则应该使用 RadioGroup像这样:

<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">


<RadioButton
android:id="@+id/radio_pirates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginLeft="100dp"
android:onClick="onRadioButtonClicked"
android:text="@string/attendance"
android:textSize="8dp"

/>
<RadioButton
android:id="@+id/radio_pirates2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginLeft="100dp"
android:onClick="onRadioButtonClicked"
android:text="@string/attendance"
android:textSize="8dp"

/>
</RadioGroup>

如果我只有一个单选按钮,我可以删除 <RadioGroup>或者这是错误的?

最佳答案

来自doc

A radio button is a two-states button that can be either checked or unchecked. When the radio button is unchecked, the user can press or click it to check it. However, contrary to a CheckBox, a radio button cannot be unchecked by the user once checked.

但是,与复选框相反,单选按钮 一旦选中,用户就无法取消选中。

因此,如果您只想提供一个选项按钮来选择用户,请使用 CheckBoxToggleButton

关于java - 只有一个单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12949963/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com