Android get value of the selected radio button

前端 未结 8 991
慢半拍i
慢半拍i 2020-12-03 06:53

I have a RadioGroup rg1 and I want to get the value of the selected radio button.

I know that I can get the id of the selected radio button

8条回答
  •  庸人自扰
    2020-12-03 07:45

    RadioGroup bhktype_RadioGr = (RadioGroup)findViewById(R.id.bhkypeRadioGroup);
    int flatTypeId = bhktype_RadioGroup.getCheckedRadioButtonId();
    String flat_type = ((RadioButton) findViewById(flatTypeId)).getText().toString();
    

提交回复
热议问题