A working shared ViewModel between parent and child Fragments //Android Kotlin Dev Diary

I initially had a problem with the shared ViewModel because the child fragments were creating a new instance from the one held by the parent fragment.

The ViewModel instantiations below work for me:

CreateLogFragment.kt (parent)

CreateLogFoodFragment.kt (child)

CreateLogNotesFragment.kt (another child)

by activityViewModels turned things around!

Related Posts:

Posts that may be related to "A working shared ViewModel between parent and child Fragments //Android Kotlin Dev Diary":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *