Thr*_*ian 8 android android-jetpack-compose android-jetpack-compose-list
由于Jetpack Compose 1.0.0-alpha09
LazyColumn
,LazyColumnForIndexed
和行的同行已被弃用。如何LazyColumn
使用,在哪里,为什么以及我应该如何使用rememberLazyListState
?
如果您可以提供一个完整的示例,包括项目、状态和 onClick 侦听器,那将非常有帮助。
这里的文档描述了如何使用LazyColumn
而不是LazyColumnFor
.
文档中特别感兴趣的部分:
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
val itemsList = (0..5).toList()
val itemsIndexedList = listOf("A", "B", "C")
LazyColumn {
items(itemsList) {
Text("Item is $it")
}
item {
Text("Single item")
}
itemsIndexed(itemsIndexedList) { index, item ->
Text("Item at index $index is $item")
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3203 次 |
最近记录: |