Android StudioでRadioGroupをセットし、その中にラジオボタンを配置する。


次にMainActivity.ktにクリックした時の動作を記載する。
fun onRadioButtonClicked(view: View) {
btn_next.isEnabled = true
if (view is RadioButton) {
// Is the button now checked?
val checked = view.isChecked
// Check which radio button was clicked
when (view.getId()) {
R.id.rb_drive ->
if (checked) {
type = "drive"
}
R.id.rb_resume ->
if (checked) {
type = "resume"
}
R.id.rb_passport ->
if (checked) {
type = "passport"
}
R.id.rb_visa ->
if (checked) {
type = "visa"
}
}
}
}
OnClickの関数として設定して完了。

シンプルですね。