This is the first post.
I noticed it while working at Kotlin, so I output it appropriately.
"* I want to add the initial value of the Radio Button that will be added *"
Often.
list = listOf(1, 2, 3)//Meaningful information
radioGroup = findById(R.id.radio_group) as RadioGroup
for (data in list){
    val radioButton = RadioButton(this)
    if (data == 1){
        //I want to use it as an initial value!
        radioButton.isChecked = true
    }
    radioGroup.addView(radioButton)
}
The purpose I saw is checked and very good
list = listOf(1, 2, 3)//Meaningful information
radioGroup = findById(R.id.radio_group) as RadioGroup
for (data in list){
    val radioButton = RadioButton(this)
    //Register RadioButton as SubView immediately after declaration
    radioGroup.addView(radioButton)
    if (data == 1){
        //I want to use it as an initial value!
        radioButton.isChecked = true
    }
}
I did it.
Recommended Posts