Код: Выделить всё
data class Item(
val name: String,
var isSelected: Boolean,
)
Код: Выделить всё
val itemStateList = mutableStateListOf()Код: Выделить всё
LazyColumn( modifier = Modifier.fillMaxWidth(), state = listState ) {
itemsIndexed(itemList, key = { _, item: Item -> item.hashCode() }) { index, item ->
val backgroundColor =
if (itemList[index].isSelected)
MaterialTheme.colorScheme.secondary
else
Color.Transparent
CustomCard(index, background)
}
}
Код: Выделить всё
fun setSelected(index: Int) {
itemStateList[index] = itemStateList[index].copy(isSelected = true)
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... ingle-item
Мобильная версия