【发布时间】:2022-01-24 23:59:07
【问题描述】:
所以我浪费了好几天的时间,我的截止日期是明天
基本上,我有一个 mutableLiveData var,它是一个伴生对象,
当数据更新时,它会调用网格内的观察函数。
观察函数被正常调用,它执行您可以看到的打印语句,
但它完全跳过了 compose "items()" 方法中的所有内容。
有人可以帮帮我吗?我在网上找不到任何有用的东西...
@ExperimentalFoundationApi
@Composable
fun ItemsGrid() {
LazyVerticalGrid(
cells = GridCells.Fixed(3),
contentPadding = PaddingValues(8.dp)
) {
mProductsByCategoryID.observe(viewLifecycleOwner,
{ products ->
println("DATA CHANGGED ${products[0].name}")
println(mProductsByCategoryID.value?.get(0)?.name)
items(products) {
println("INSIDE ITEMS for products ${it.name}") // never gets inside of here except for the first time the view loads
DemoCards(demo = it)
}
}
)
}
}
【问题讨论】:
标签: android kotlin android-livedata android-jetpack android-jetpack-navigation