LazyColumn(modifier = Modifier.fillMaxWidth(), state = listState) {
//ABC Category Items
item {
ABC(componentCoordinator = componentCoordinator)
}
//DEF Category Items
item {
DEF(coordinator = screenCoordinator)
}
//IJK Category Items
item {
IJK()
}
//XYZ Category Items
item {
XYZ(coordinator = screenCoordinator)
}
}
@Composable
fun ABC(
viewModel: ViewModel = hiltViewModel(),
componentCoordinator: ComponentCoordinator
) {
LazyRow(
modifier = Modifier
.fillMaxWidth()
.height(64.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
) {
.........
})
所有的ABC, DEF, IJK, XYZ都是具有Column, Row, LazyRow组合的可组合方法。
我必须使它们都在单独的项目{}中,以便根据它们的索引分别跳转它们(使用listState.animateScrollToItem(int))。现在,创建LazyColumn的更好的方法是使用"items"(而不是"item")参数
像这样:
LazyColumn(
modifier = Modifier.fillMaxWidth(), state = listState
) {
items(myItems, key = { it.uri }) { item ->
....
})
this和LazyColumn函数体的Array初始化代码(因为这些方法没有相同的参数)是什么?
var itemsList = mutableStateListOf<@Composable (vararg : Any) -> Unit>)
存储所有可组合文件