如何更改单选按钮组中单选按钮的状态? 我从Firebase获取了值Male或Female(存储在单选组之外),然后再次填充Layout。现在,我必须将“男性”信息转换为单选组的单选按钮
var rg = radioGruppe
rg!!.setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener
{
group, checkedId ->
Log.i("test", "The ID is: ${group.checkedRadioButtonId}")
})
ID为:2131230874 但是我现在该怎么办?
答案 0 :(得分:0)
由我自己找到:
rbMale = mView?.findViewById((R.id.rb_male))
rbFemale = mView?.findViewById((R.id.rb_female))
if(Gender == "Woman") {
radioGruppe!!.check(rbFemale!!.id)
} else {
radioGruppe!!.check(rbMale!!.id)
}