Denis
02/06/2021, 10:03 AMcounts
list on each tap. I expect it to render a new Count
and somehow move previous rows down without calling Count
again. Is it possible?
@Composable
fun CounterApp() {
var counts by remember { mutableStateOf(listOf<Int>()) }
var taps by remember { mutableStateOf(0) }
Column(
modifier = Modifier.fillMaxSize().clickable(onClick = {
counts = listOf(taps) + counts; taps++
})
) { Text("$taps"); Divider(); counts.forEach { Count(it) } }
}
@Composable
fun Count(n: Int) {
Log.d("Count", "$n")
Text("$n")
}
Rafs
02/06/2021, 10:24 AMmutableStateOf(listOf<Int>))
you should be using mutableStateListOf<Int>
Denis
02/07/2021, 6:57 AM