How can i show the selected chips in chip group android

102 Views Asked by At

I am working on an property listing application where users can list their property like rooms etc. Now the problem I m facing is in the "update listing details" part. So basically we have four fragments through that user fill their property details and then finally it got posted on our platform. Now when user wants to make any changes in their property listing details user have to go through the same four fragments to update the details of their property. Here i m facing the problem when user clicks the update listing button the first fragment opens with chip groups which user selected before during listing their property now I want that the chip groups should show the selected chips which user selected while listing their property. I have no idea how can i do this. Please guide me.

Here The Image of first fragment in listing property as we can see that this does not show selected chips which user selected during listing property enter image description here

1

There are 1 best solutions below

3
Narendra_Nath On

Take the data from a shared ViewModel with the Activity which houses the fragments as a lifecycle owner.

eg: val ViewModel:MainActivityViewModel by activityViewModels

Then set the first fragment to observe the selected properties . Since the source of your data remains the same you can manipulate how to show the selected items from there