Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何取消选中android中的单选按钮(在radiogroup中)?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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中)?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。