Set selected index of an Android RadioGroup

前端 未结 7 1051
予麋鹿
予麋鹿 2021-02-01 11:52

Is there a way to set the selected index of a RadioGroup in android, other than looping through the child radiobuttons and selecting checking the radio button at the selected in

7条回答
  •  失恋的感觉
    2021-02-01 12:18

    Using Kotlin you can make it by

      (radio_group_id.getChildAt(index) as RadioButton).isChecked = true
    

    or

    radio_group_id.check(R.id.radio_button_id)

提交回复
热议问题