final RadioGroup radioGroup=(RadioGroup) findViewById(R.id.radioGroup1); final RadioButton rb0=(RadioButton) findViewById(R.id.radio0); final RadioButton rb1=(RadioButton) findViewById(R.id.radio1); radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub switch (checkedId) { case R.id.radio0: radioGroup.check(rb0.getId()); break; case R.id.radio1: radioGroup.check(rb1.getId()); break; default: break; } System.out.println(); } }); Button btn =(Button) findViewById(R.id.btn); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { radioGroup.clearCheck(); } });
布局文件activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checkedButton="@+id/radio0" > <RadioButton android:id="@+id/radio0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RB0" /> <RadioButton android:id="@+id/radio1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RB1" /> </RadioGroup> <Button android:id="@+id/btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="点击" /> </LinearLayout>
相关推荐
两个radioButton选中其中一个弹出选中的值对话框,也可用在数据库如(男或女)
Android进阶之RadioButton选中值的获取、单选多行,解决很多选中去不掉色的效果
VC 获取RadioButton控件选中值,在平时的使用中,选中的RadioButton会有一个值传递到下一个环节中,本实例就是展示了如何获取用户选中的值。下面请看具体代码: void CDemoDlg::OnTest() { //获得组中单选...
获取RadioButton选中值第一种方式通过RadioGroup的setOnCheckedChangeListener()来监听选中哪一个单选按钮// 通过R
开发语言C#,开发环境.net,控制控件RadioButton进行美化。
使用RadioButton切换Fragment,滑动切换的时候有动画
RadioButton实现选择后可取消选择,利用wpf技术实现
C#的winform是没有webform的RadioButtonList和CheckBoxList这两个...要实现从数据库取出数据后动态生成N个RadioButton和CheckBox并获取选中项目的值,请看本例。思路很简单,有问题请指出,相互学习共同进步,谢谢。
在项目中遇到buttonGroup下的3个radioButton在选中后,不能恢复初始的全不选状态。经过CSDN论坛陈年椰子的指点,实现了该功能。 特做了演示工程,实际测试可用。贡献给同样有困惑的同学。 本工程的模块版本如下: ...
Javascript获取被选中的Radio button的值或者文本。
WPF 实现RadioButton样式两种方式:1资源样式 2代码调用资源样式 ,vs2010
最近写项目有个需求是单选框必须改成设计要的样子,然后再网上找了好久,自己调试了一下,就好了
嵌套的在GridView里的radiobutton 怎么才能只选中一个_asp_net(c#)
Android自定义RadioButton和CheckBox样式,重写RadioButton的onDraw()方法,实现颜色选择器效果。
一个非常好的示例,值得一看
支持tab导航,网络图片; 加载网络图片后,选中的放大,未选中的原始尺寸 通过radioButton实现的导航 导航中间有原型组件。
本资源项目,对于eclipse和Android studio两种开发...2.可以点击radiobutton 改变选中状态,进行切换fragment。 3.由于用了viewpager,也可以左右滑动。 4.代码完整,注释清晰,导入即用。 5.用好了请给个评价,谢谢!
JavaScript 关于checkBox 全选 单选 RadioButton 全选 单选 制定用户选中页面控件;等......