选择和取消选择单选按钮 [英] Selecting and deselecting radio buttons

查看:148
本文介绍了选择和取消选择单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发它由一个问题,三个选项的测验应用程序,我使用的单选按钮,这些options.My查询,我点击的选项之一,每当我想点击另一个选项,previous选项保持在选中状态,它不会每当我在第三个选项,点击过一样。
我需要在哪里,它的行为作为一种天然的单选按钮,只有一个选项是在任何时间点检查的解决方案。

I am developing a quiz application which consists of a question and three options and I am using radio buttons for these options.My query is,I click on one of the options and whenever i want to click another option, the previous option remains in the checked state and it does the same whenever I click on the third option too. I need a solution where in it behaves as a natural radio button,only one option is checked at any point of time.

推荐答案

使用RadioGroup中您可以将单选按钮。
下面是例子,如何您可以将使用RadioGroup中的单选按钮

You can group RadioButtons using the RadioGroup. Here is the example how you can group the RadioButtons using RadioGroup

<RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_content" android:layout_height="wrap_content">
        <RadioButton android:text="RadioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/radio0" android:checked="true"></RadioButton>
        <RadioButton android:text="RadioButton" android:layout_width="wrap_content" android:id="@+id/radioButton1" android:layout_height="wrap_content"></RadioButton>
</RadioGroup>

有关详细信息,您可以参阅这个文件

For more information you can refer this document

这篇关于选择和取消选择单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆