如下代码所示,我得到了list
(类型:Flow<List< T
>>),
如何使用它来更新lazyColumn的项目,所以当房间数据发生变化时,lazyColumn会相应地更新项目?
非常感谢。
@Composable
fun SomeContent(context: Context) {
// get the view model ref
val viewModel: SomeViewModel =
viewModel(factory = SomeViewModelFactory(Db.getInstance(context)))
// get the list from room, it is a Flow list
val list = viewModel.sumDao.getAllRows()
LazyColumn(
) {
// I need to use the list in below, but got errors, how to do?
items(list.size) {
SomeListItem(list[it])
}
}
}