Mahdi
11/15/2020, 8:49 AMval items = viewModel.liveDataItems.observeAsState(initial = emptyList())
After user do some action I wanna expand that specific item. For do that I will tell viewModel update expandation field of selected item. Then I will update liveDataItems and want to expandations happens. I have two problem here, first making change to list items not trigger Live Data in compose so I have to replace all data with new that specific items is updated with isExpanded=true. Second issue is with tis way I will lose my scroll point and view will render from start. How I can handle expandation like this to havePavel Marchenko
11/15/2020, 12:22 PMLiveData
does not observe changes inside the data
, only changes of data
itself.
Regarding second problem, scroll position is stored in LazyListState
or ScrollState
or similar, depending on what scrollable composable you are using. Usually scrollable composable remembers scroll state and it survives recomposition, so to resolve this problem you need to understand why scroll state is recreated in your case, without actual code it is hard to guess.Mahdi
11/16/2020, 1:23 AM