Uncheck all RadioButton in a RadioButtonGroup

后端 未结 3 775
借酒劲吻你
借酒劲吻你 2020-12-06 03:38

What I wanted to achieve is this: Right after the activity starts, I want that no RadioButton is selected/checked.

My problem is this: When the activity starts, the

相关标签:
3条回答
  • 2020-12-06 04:30

    use clearCheck() for clearing all checked radiobutton when acticity is started or resumed

     @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
     RadioGroup rg=(RadioGroup)findViewById(R.id.RG);
    rg.clearCheck();
    }
    @Override
    protected void onResume() {  
    RadioGroup rg=(RadioGroup)findViewById(R.id.RG);
    rg.clearCheck();  
    super.onResume();  
        }  
    
    0 讨论(0)
  • 2020-12-06 04:36
    RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radiogroup);
    radioGroup.clearCheck();
    
    0 讨论(0)
  • 2020-12-06 04:42

    use this

    RadioButton spec1=findViewById(yourRadioGroup.getCheckedRadioButtonId());
            if (spec1.isChecked())
            {
                spec1.setChecked(false);
            }
    
    0 讨论(0)
提交回复
热议问题