How to access the current item's index of LazyColumn in Jetpack Compose.
LazyColumn {
items(viewModel.list) { item ->
// Here I want to get the index of the item
Timber.d("item - $item")
}
}
How to access the current item's index of LazyColumn in Jetpack Compose.
LazyColumn {
items(viewModel.list) { item ->
// Here I want to get the index of the item
Timber.d("item - $item")
}
}
You can use the itemsIndexed()
extension function which provides the index
.
LazyColumn() {
itemsIndexed(viewModel.list) { index, item ->
//..
}
}
© 2022 - 2024 — McMap. All rights reserved.
itemsIndexed(itemsList) { index, item ->
instead ofitems
– Lithometeor