
RadioGroup group=(RadioGroup)findvIEwbyID(R.ID.group); Radiobutton b=(Radiobutton)findvIEwbyID(R.ID.button); Radiobutton b1=(Radiobutton)findvIEwbyID(R.ID.button1); Radiobutton b2=(Radiobutton)findvIEwbyID(R.ID.button2); group.setonCheckedchangelistener(new RadioGroup.OnCheckedchangelistener() { @OverrIDe public voID onCheckedChanged(RadioGroup group,int checkedID) { // Todo auto-generated method stub selected=(Radiobutton)findVIEwByID(checkedID); userAnswer=selected.getText().toString(); } }); button=(button)findvIEwbyID(R.ID.butn); button.setonclickListener(new VIEw.OnclickListener(){ voID onclick() { group.clearCheck(); } }); 我的要求是每当用户点击下一个按钮时我需要显示单选按钮作为选项而没有选择.如果用户单击一个选项,他点击下一个按钮,然后点击他之前单击(选中)的选项,下次自动选择在此之前,我需要清除放射线组中的无线电按钮,因为我必须做的……
提前致谢…….
解决方法 您还在xml中的RadioGroup VIEw中添加了Radiobuttons吗?如果不是,则需要将它们添加到您正在使用的RadioGroup对象中您需要使用RadioGroup中的方法
voID check(int ID) Sets the selection to the radio button whose IDentifIEr is passed in parameter. voID clearCheck() /// This method will clear the selection of all the members of RadioGroup
例如,如果rg是RadioGroup的变量
rg.check(); rg.clearCheck();总结
以上是内存溢出为你收集整理的如何取消选中android中的单选按钮(在radiogroup中)?全部内容,希望文章能够帮你解决如何取消选中android中的单选按钮(在radiogroup中)?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)