I have a usecase when item of lazy column is click...
# compose
m
I have a usecase when item of lazy column is clicked i need to expand the state of that item also i need to collapse the item which is already expanded, I'm not able understand how to collapse already expanded item. Please help
s
You can try making a state
expandedItemId
that stores the id of the expanded item so when you change the expanded item, the other items will collapse Something like this:
Copy code
var expandedItemId by mutableStateOf<String?>(null)
LazyColumn {
    items { item ->
        Item(
            expanded = item.id == expandedItemId,
            onExpandChange = { expandedItemId = item.id }
        )
    }
}