https://kotlinlang.org logo
Title
v

Vince

05/12/2023, 3:12 AM
Is there a way to “group” items across composables? So for instance
@Composable
fun Main() {
  Row()
  Row()
  Row()
}

@Composable Row() {
  Row {
    CheckBox()
    CheckBox()
    CheckBox()
  }
}
Is it possible to disable the first checkbox in the other two rows once it’s checked in one row?
j

jw

05/12/2023, 3:43 AM
Give each row an index. Pass it into the
Row
function. Next, maintain a List<Int> of the checks. Each row loops over this list and each checkbox only enabled if the value at its column index is
-1
(unchecked) or
== rowIndex
. When you check a checkbox, write its
rowIndex
into the list at the index matching the column index.