Skip to content
Advertisement

Passing data from a Pop up back to its Parent

The parent class activity consists of adapters and recycler views. Using one of the adapters the one click is set for images. If an image is clicked it opens a pop-up and the pop have some sliders and text fields. And the pop-up will collect data from users.

Now I need this data, not in the adapter class but I need it in the parent class.

So can I proceed with this execution? So can anyone help to provide me with a suitable way to create the pop-up and transfer data to the adapter class and then to the parent class? Thank you all in advance.

Advertisement

Answer

Imagining you are navigating between fragments, the easiest way to do this is to use a SharedViewModel. Both the parent and the dialog will be able to access the data contained in it.

This link should help: https://developer.android.com/topic/libraries/architecture/viewmodel#sharing

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement