Android: Share Data Between Fragments Using ViewModel

preview_player
Показать описание
In this video, we are going to learn how to pass data between Android fragments using the ViewModel.

Subscribe for more tutorials

Source Code:

➞ Artist: Ron Gelinas
➞ Track Title: Connecting (original mix)
Рекомендации по теме
Комментарии
Автор

from 00:16:00 its the topic about (shared) viewmodel ... not needed to know about recyclerview and tooo long to geto to the point (imho) :S

marlonlom
Автор

I’m working on a feature in my app that allows the user to enter information inside 4 different fragments and I want to store that information and in the last fragment I have a button that will store all of the user input to a database. How would I go about doing that? I tried Bundle() but I keep getting null pointers. How can I save user input across multiple fragments not just one fragment to the other.

AliFX
Автор

Thank you for this footage. When I rotate my phone two fragments are overlapped. Would you please let me know the reason?

peterkim
Автор

Why no one explaining how can we change text in fragment from related viewmodel from mainactivity????
no one knows?

ideeprogrammer-pvt-ltd
Автор

I don't think its a good design for fragments to know about each other. A better design would be the using the Activity to start the DetailFragment.

stevemason
Автор

pro tip: if like me you are have a lot of fragments and you are finding it complicated transferring data among them all use Singleton pattern

anb
welcome to shbcf.ru