0

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 Answers1

1

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

Narendra_Nath
  • 4,578
  • 3
  • 13
  • 31
  • narendra brother thank you for response but i did not get it completely?? – Puru Chaudhary Feb 28 '23 at 14:51
  • 1
    Sure man.. basically you have to have a single source of data/ truth. the only way you can do that is via a sharedviewmodel – Narendra_Nath Feb 28 '23 at 20:52
  • narendra bhai i am using the sharedviewmodel to save the data in the firebase but i am not asking that brother i am asking about while updating the details in firebase how can i show the data in the chips – Puru Chaudhary Mar 01 '23 at 16:25