Hi, I have a list of composables that look like th...
# compose
n
Hi, I have a list of composables that look like this (please see above). I have a Boolean called isDisabled, and I want to assign it to other composables when I select one of them. How can I achieve that? I have now spent two weeks trying everything I can think of, but with no success.
f
Maybe something like this:
Copy code
@Composable
fun SelectedExample() {
    val selectedIndex = remember { mutableStateOf(0) }

    Column {
        listOf("A", "B", "C").forEachIndexed { index, string ->
            Card(
                Modifier.clickable(onClick = { selectedIndex.value = index }),
                elevation = 8.dp
            ) {
                val isSelected = selectedIndex.value == index
                Text("This is a Card " + string + " isSelected:  " + isSelected)
            }
        }
    }
}
n
Oh thanks @Foso, I'll give this a try! 😊