'Recompose when back to activity
I have an activity with a list of items (LazyColumn). When I click on an item, it launches a new activity to edit the item. If I change the item and save it, go back to the main activity and I want to recompose the list. I am initiating Jetpack compose and I need help to recompose the layout. I have this code but this does not work.
@Composable
fun content(
viewModel: MealsViewModel,
selected: (Meal) -> Unit,
longClicked: (Meal) -> Unit
) {
val listState = rememberLazyListState()
LazyColumn(
state = listState,
modifier = Modifier.fillMaxWidth(),
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp),
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
itemsIndexed(items = viewModel.meals.value) { i, meal ->
MealListItem(viewModel.meals.value[i], selected, longClicked)
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
