#2 Android ViewModel Tutorial - Android Architecture Component - Jetpack Tutorial - MVVM tutorial

Опубликовано: 03 Февраль 2020
на канале: Munir Hoque
1,104
18

This video tutorial is all about the ViewModel. We will learn how to use android ViewModel in our project.

ViewModel is an android architecture component which basically have 2 attributes -
Holds all UI related data for UI controller(Activity/Fragment)
Survives any runtime configuration changes like rotate phone from Landscape to portrait and vice versa.
Starter Project download link : https://bit.ly/2UmN4bt
First part link -    • #1 Android ViewModel and LiveData Tutorial...  

Full Playlist link :    • Android ViewModel and LiveData  

ViewModel and LiveData dependency -
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'


 Let’s consider the current situation. Right now all our UI related data are inside Fragment. And when we rotate our phone, the runtime configuration is changed. After that Android OS internal system recreates our Fragment, but our valuable data is lost already if we do not take any action to save data.

Here comes the ViewModel to save us from this situation. We store our UI related data into ViewModel instead of saving inside Fragment. And thus we make an association between our fragment and the ViewModel.
Now when we rotate our phone and the configuration changes and after that the Fragment is recreated. As we have an association with ViewModel we can get all our UI data to show inside our Fragment.



#AndroidViewModel
#AndroidAppDevelopmentTutorial
#MVVMTutorial
#AndroidMVVM


На этой странице сайта вы можете посмотреть видео онлайн #2 Android ViewModel Tutorial - Android Architecture Component - Jetpack Tutorial - MVVM tutorial длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Munir Hoque 03 Февраль 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,104 раз и оно понравилось 18 зрителям. Приятного просмотра!