【发布时间】:2021-07-19 19:00:42
【问题描述】:
我正在尝试使用 LazyVerticalGrid 显示分页项目。我正在尝试的代码如下所示。
val categories = repo.categories.collectAsLazyPagingItems()
LazyVerticalGrid(
cells = GridCells.Fixed(2),
modifier = Modifier.padding(8.dp)
) {
items(categories) { category ->
Box(Modifier.padding(8.dp)) {
CategoryView(category)
}
}
}
请注意我已经导入了androidx.paging.compose.items 和androidx.paging.compose.collectAsLazyPagingItems。 categories 的类型也是 LazyPagingItems<Category>。
它与LazyColumn 和LazyRow 完美搭配,但不适用于LazyVerticalGrid。
我得到的错误是:
Type mismatch.
Required:
Int
Found:
LazyPagingItems<Category>
【问题讨论】:
标签: android android-jetpack-compose android-paging-3