Тёмный

ViewModel Explained - Android Architecture Component | Tutorial 

Stevdza-San
Подписаться 85 тыс.
Просмотров 111 тыс.
50% 1

🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN
stevdza-san.com
🐱‍👤 Wanna become a member? Join!
/ @stevdzasan
📸 Instagram
/ stevdza_san
// ViewModel dependency
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
The ViewModel class is designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations. So when we are talking about Activity or Fragment we are actualy refering to UI Controllers. And ViewModel class should be created for each UI Controller in order to separate things like data and diferent calculations from UI Controler. In UI Controller there should only be necessary code for managing our UI, and everything else we could placed inside a ViewModel class.
Timestamps
0:00 - Introducing with ViewModel
1:30 - Practical example with ViewModel
6:30 - Conclusion

Опубликовано:

 

23 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 148   
@ben6
@ben6 3 года назад
Wow, this is so modern! Finally a video that feels from 2020
@mahmoudbasha516
@mahmoudbasha516 4 года назад
Man you're good in this teaching stuff !! If everyone trying to explain something is organized, straight to the point, covering the whole subject as you the world would have been a much better place. Thank you and please go on with this art you're creating
@StevdzaSan
@StevdzaSan 4 года назад
Thank you for your kind words, I really appreciate that
@faboxbkn
@faboxbkn 2 года назад
Man I have been struggling to find a short video straight to the point! excellent nice explained. 10/10
@theMajesticMJ
@theMajesticMJ 3 года назад
Thank you very much. you don't have any idea that how helpful your tutorials have been for me in last few months.
@TheDamiankain
@TheDamiankain Год назад
That feeling when a foreigner explains in a shorter and clearer way than compatriots. Thank you, this is the shortest and most understandable video on the viewmodel that I have seen!!!!!
@solidlucho1
@solidlucho1 3 года назад
Thank you!! , I was chewing and watching tutorials, and this video was the one that could open the picture for me
@freddygoudou801
@freddygoudou801 4 года назад
Il n'y a pas plus simple façon d'expliquer. Love this tutorial!
@MarcelloLins
@MarcelloLins Год назад
Excellent video ! Drove the point home with a practical example. Very easy to follow ! Thanks a ton !
@gesit7120
@gesit7120 4 года назад
Good short easy to understand tutorial, keep your work up👍
@davidgreenwitch
@davidgreenwitch Год назад
Thanks. Short and precise. Just what I needed.
@tmjromao
@tmjromao 3 года назад
Excellent tutorial! Easy as it has to be. Very helpful. Many thanks for doing and sharing it
@iamskyhorse
@iamskyhorse 2 года назад
Thank you. The best tutorial I have seen. You have good teaching skill how to use simple example to transfer the knowledge to students effectively.
@tonyblack1981
@tonyblack1981 3 года назад
Perfect, just the explanation I needed. Thank you
@a-zlearning6259
@a-zlearning6259 5 месяцев назад
Thank you. Your explanation is clear and easy to understand!
@silentassassin7472
@silentassassin7472 3 года назад
Most modern android tutorial..plz keep making them
@chriscampbell5901
@chriscampbell5901 3 года назад
Thanks for not over complicating this subject.
@nikisurf
@nikisurf 4 года назад
Nice video man.. I am a developer but, the way you teach people is extraordinary.
@rinkup2639
@rinkup2639 Год назад
Videos are concise, to the point and relevant
@raunakkumar6144
@raunakkumar6144 Год назад
Thanks man , loved your explanation.
@donnfelkeryt
@donnfelkeryt 2 года назад
Excellent tutorial. Short, succinct and to the point. Well done.👏
@StevdzaSan
@StevdzaSan 2 года назад
Thank you 🙏🙌
@anb4351
@anb4351 Год назад
Thanks man now I will never get confuses on what is ViewModel
@mkrdeveloper
@mkrdeveloper Год назад
fantastic as always
@ayoseunsolomon2562
@ayoseunsolomon2562 3 года назад
Thank you so much, so simple and powerful, learning shouldn't be ambiguous, thank you so much for making this so simple
@StevdzaSan
@StevdzaSan 3 года назад
I'm glad you like it 💜🙏
@khaxbiker
@khaxbiker 3 года назад
Geat video. Clear and simple. I learnt a lot. Ty
@nirmalrevar
@nirmalrevar 3 года назад
Nicely Explained. After watching your 1 video I subscribed.
@lucye7320
@lucye7320 4 года назад
Awesome video, nice example. Thank you!
@VenewebTV
@VenewebTV Год назад
Excellent Video, very useful. Regards from Caracas, Venezuela
@wreckeddroid8800
@wreckeddroid8800 2 года назад
wow.. explanation level ..just wow
@faryzryz1482
@faryzryz1482 3 года назад
WOW!, thanks for the great video , it helps me A LOT! Good Job
@alexgireff2180
@alexgireff2180 2 года назад
Everything is clear. Nice 👍
@Sippi200
@Sippi200 3 года назад
Thanks! Really good for a beginner like me!
@xaviersoh
@xaviersoh Год назад
Very clean and focus
@fazaljarral2792
@fazaljarral2792 3 года назад
Straight forward and easy.
@redaantar8908
@redaantar8908 3 года назад
you are the best man i swear
@mohamedayad70
@mohamedayad70 3 года назад
you made it looks too easy :D ty sir
@user-pf2bw4uf6l
@user-pf2bw4uf6l 2 года назад
Great video man!! You have save me from various headaches
@StevdzaSan
@StevdzaSan 2 года назад
Yay! 🙌
@xaviersoh
@xaviersoh Год назад
Welle explained, straight to the point . I don't understand english very well but here averything is clear
@iqbalrivaldi2856
@iqbalrivaldi2856 Год назад
Good video bro, thia video have a nice explanation about view model and example practice. Good job
@tayyab222222
@tayyab222222 Год назад
To the point, excellent explanation, thanks..
@pushpendratripathi46
@pushpendratripathi46 4 года назад
Thanks for this great information.
@k.snithin9456
@k.snithin9456 2 года назад
Thank you for explaining using simple and easy to understand examples.
@brucebane7401
@brucebane7401 3 года назад
amazing !!!! simply amazing thank you so much
@Danny.Rivver
@Danny.Rivver 2 года назад
Your videos have helped me soo much. thank you soo much for the amazing content!
@StevdzaSan
@StevdzaSan 2 года назад
I'm glad to help! 🚀✌
@streameranal
@streameranal 3 года назад
Thanks a lot, you explain perfectly!
@maskmanlifestyle
@maskmanlifestyle 3 месяца назад
Thank you for the video ❤
@lilianpuzo225
@lilianpuzo225 4 года назад
Your videos are awesome. Thanks
@thisaditya7
@thisaditya7 Год назад
Loved it
@keshavjha9835
@keshavjha9835 3 года назад
simple and clear explanation
@iftak01
@iftak01 3 года назад
Great example
@user-ci9hj3qp4e
@user-ci9hj3qp4e 2 года назад
amazin explanation!!!! thank you a lot!
@youssoufcameroon2565
@youssoufcameroon2565 Год назад
Sir, you are a legend
@Kunal-jp8tn
@Kunal-jp8tn 2 года назад
Thank you so much for this amazing content.....
@retajkamal8719
@retajkamal8719 3 года назад
Thank you for the explanation
@pradeep9222
@pradeep9222 2 года назад
thank you, it's helpful
@StevdzaSan
@StevdzaSan 2 года назад
You're welcome
@alperencevlik3104
@alperencevlik3104 3 года назад
You're the man!
@johndominicjasmin
@johndominicjasmin 2 года назад
Thank you so much
@user-ps2yx2bw8t
@user-ps2yx2bw8t 4 года назад
A lesson in how to retrieve data to RecyclerView from Firebase database can be done and arranged according to the higher value or the higher price.
@hachij_
@hachij_ 4 года назад
Thank you! simple
@aathilahamed5871
@aathilahamed5871 3 года назад
Amazing keep going
@Aspiret620
@Aspiret620 3 года назад
so good tutorial
@ardhanmaulana7873
@ardhanmaulana7873 3 года назад
woah nice tutorial man. it straight to the point. i just learn android jetpack and i love your content.
@bro_chenzox
@bro_chenzox 4 года назад
One more thanks for one more light video.
@UniformDelta00
@UniformDelta00 4 года назад
short videos about view model are so few and far between! I got the idea of the purpose of view model thnks
@tavoochoa100
@tavoochoa100 3 года назад
question, don't we need to implement the library? or the current androidDx thing implements it by default?
@wilsonneto6035
@wilsonneto6035 2 года назад
good stuff
@nguyenquanghuy5709
@nguyenquanghuy5709 Месяц назад
thanks a lot
@halilmertdeveli3846
@halilmertdeveli3846 Год назад
I got now thank you
@fyanahmad9418
@fyanahmad9418 4 года назад
thanks man
@chunkies839
@chunkies839 2 года назад
so its just a seperate class where all the logic takes place while the main activity is just there to facilitate displaying information correctly?
@surabhidixit8809
@surabhidixit8809 3 года назад
Hi can you explain savedstatehandle in viewmodel with example I am not clear about the use Thank you
@TheMikkelet
@TheMikkelet 3 года назад
So using a viewmodel in an MVP architecture is a no-go? Because view and presenter indirectly holds a reference to eachother (although usually injected by dagger or hilt)?
@psxbrasil
@psxbrasil Год назад
I have a question. How you can declare "textView.text" without use the "findViewById" method before? How did you get the reference to the TextView element?
@bjugdbjk
@bjugdbjk 3 года назад
Great tutorial !!! I want to learn something advance concepts of viewmodel.Do u have anything which I can refer..!!!
@RRRazzzaRRR
@RRRazzzaRRR 3 года назад
thnx,
@tommy9x
@tommy9x 2 года назад
The onClear explain should be clearer, I not find the Playlist for ViewModel on your Channel, can you create one? And could you give Viewmodel course for Jetpack Compose please?
@RonaldoGuedes
@RonaldoGuedes 2 года назад
Hello!!! First of all, you really know how to explain and let until a dumb get it! thanks
@StevdzaSan
@StevdzaSan 2 года назад
Thanks buddy, we're all dumb sometimes 😄
@danmccray8201
@danmccray8201 2 года назад
Is there any difference when implementing this with Jetpack Compose?
@scalarcoding
@scalarcoding 9 месяцев назад
so basically when user do some system changes in screen orientation or theme, then the UI will be repaint itself, right? I wonder if it's the same as flutter's statefulwidget
@user-my6yf1st8z
@user-my6yf1st8z Год назад
2:06 how does he find button and text views without findViewById or viewbinding?
@lilianpuzo225
@lilianpuzo225 3 года назад
is there any video about share view model? thanks
@cyruscantero9376
@cyruscantero9376 2 года назад
Hello we do this on fragment? are the process same??
@princedeka6054
@princedeka6054 3 года назад
New subscriber 😎👍
@StevdzaSan
@StevdzaSan 3 года назад
Welcome! 🥳🚀
@zohaib9381
@zohaib9381 4 года назад
Great video, can u make a video on rxjava
@zhe1ka353
@zhe1ka353 3 года назад
when i go to another Activity and then get back - the data is lost, is it as expected? is there any way to keep it persistently?
@ldxyz-s1e
@ldxyz-s1e Год назад
Is ViewModel life longer than Activitiy or it saves/restores the data by serializing the class and storing it?
@tessanix9771
@tessanix9771 Год назад
Thank you for these explainations but I think that "remember { State }" keywords does the same things. They allow a composable to remember states/variables during it's lifecycle. Correct me if I'm wrong please.
@pawmeowzing2906
@pawmeowzing2906 Год назад
why not prevent ui recreate when device rotate from androidmanifest?
@anshulkumar991
@anshulkumar991 4 года назад
Hello I need help so how I contact you
@randy4443
@randy4443 4 года назад
Can you make a tutorial of viewmodel with fragments?
@olamao
@olamao 4 года назад
Thanks a lot Stefan. Should I have my string array data for recyclerview in ViewModel? I have issues with my recycler view when rotating the phone. I have the data in sqlite and a function to read the data. However it is not clear to me if each string array should be treated in the way you did in this video. I really appreciate your tutorials.
@StevdzaSan
@StevdzaSan 4 года назад
Well if you want your data to be saved when you rotate the screen, you should put the data in viewmodel. However if it is a big hassle, you could just set your app to be in portrait mode. Because not restricting landscape mode, means you need to create landscape layouts for all your screens.
@olamao
@olamao 4 года назад
@@StevdzaSan Thanks.I will restrict the app to portrait mode in the short run.
@olamao
@olamao 4 года назад
@@StevdzaSan I don't have calculations that I have to save. I update my database each time the user takes an action that requires so. However, the onclicklistener stops working. I play a little sound when the user clicks an action is taken, but when it changes to landscape the sounds is not played any longer. Best regards Mauricio
@jorgeleonardogamarraospino9896
@jorgeleonardogamarraospino9896 3 года назад
How can I do this but with an edittex ?
@uu-wl8gw
@uu-wl8gw 3 года назад
Is Viewmodel only implemented for Kotlin? because everywhere I search about mvvm topic, most of the examples are in Kotlin.
@thabangmotloung3895
@thabangmotloung3895 3 года назад
nice video, but you forgot to show us when you added the dependency for viewmodel.
@idrissamari2733
@idrissamari2733 Год назад
i'm getting an error in viewmodel provider owner always i checked all implementation and still
@brandondelacruz934
@brandondelacruz934 3 года назад
When i see Stevdza-San's tutrotials Me: *Like... *+1 iq
@EvanTempleton
@EvanTempleton 3 года назад
How are you getting the reference to Button at 1:53? Is this something in your imports?
@StevdzaSan
@StevdzaSan 3 года назад
Kotlinx.synthetic is deprecated. Use ViewBinding now, I made a video about it.
@EvanTempleton
@EvanTempleton 3 года назад
@@StevdzaSan Thank you! Watching it now.
@harisiqbal9120
@harisiqbal9120 2 года назад
Can I make viewmodel for every view (Activity, Fragment)
@StevdzaSan
@StevdzaSan 2 года назад
Yep 👌
@RonaldoGuedes
@RonaldoGuedes 2 года назад
How can I use a button like you, without instance the var with the findViewById... the way you did is pretty good, but I can't do like you.. my Android Studio didn't get the button.
@StevdzaSan
@StevdzaSan 2 года назад
View Binding
@RonaldoGuedes
@RonaldoGuedes 2 года назад
@@StevdzaSan I didnt see it in your code, are you sure? that activity was empity, no reference to viewBinding
@zoranjankovic3363
@zoranjankovic3363 3 года назад
Pozdrav Stefane, da li mogu dobiti tvoj kontakt na koji mogu da ti se javim?
@Adam0001
@Adam0001 3 года назад
How can i rotate my own mobile?? i do not use emulator
Далее
Smart Sigma Kid #funny #sigma #comedy
00:26
Просмотров 10 млн
Everything you need to know about Kotlin 2.0 🟣
11:05
Room в Jetpack Compose | Android Studio + Kotlin
1:05:54
Let, Also, Apply, Run, With - Kotlin Scope Functions
11:44
Model View View-Model (MVVM): Getting Started
29:12
Просмотров 397 тыс.
por que parei de usar Vim depois de 2 anos de uso
14:44
Android ViewBinding in 8 Minutes
8:59
Просмотров 75 тыс.
RecyclerView | Everything You Need to Know
25:07
Просмотров 131 тыс.