Shared ViewModel - Explained | Android Studio Tutorial

  Рет қаралды 45,348

Stevdza-San

Stevdza-San

Күн бұрын

Пікірлер: 95
@toncatzu
@toncatzu 2 жыл бұрын
I just want to tell you that you saved me from further stress today. Been having a problem with a parent fragment and its child fragment that are supposed to share one viewmodel. The key was "activityViewModels". Thanks for explaining what it's for!
@StevdzaSan
@StevdzaSan 2 жыл бұрын
Happy to help with the stress! 😎
@bharathprakash
@bharathprakash Жыл бұрын
Sir thank you so much !! Clear explanation Lot's of love from India ❤
@AmitJayant
@AmitJayant 2 жыл бұрын
Very precisely explained. Thanks a lot for this. ❤️ From India
@mwahajsajidali5799
@mwahajsajidali5799 10 ай бұрын
Thanks man, I am learning android development, and I am working on a project which uses the concepts of navigation. I wanted to retrieve data from 1st Fragment. I tried everything like I tried data Classes to save data from 1st Fragment and use it in the 2nd Fragment but it did'nt work. Then, I realized that there must be another way of communication between two Fragments. Thank You very much for this information.
@herisarwanto1183
@herisarwanto1183 3 жыл бұрын
Nice. Easy to understand, and well explain too
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Glad to hear that 💜
@tylerryden
@tylerryden Жыл бұрын
Thank you! Simple, straight to the point, and now I have a great understanding as to how to share data between fragments tied to the same activity.
@tadiyal04
@tadiyal04 3 жыл бұрын
No words for your tutorial . u hit the bull eye
@batuhans.5120
@batuhans.5120 5 ай бұрын
Very simple and giving good inspiration thanks for well education
@irvingj.villanueva2318
@irvingj.villanueva2318 2 жыл бұрын
Just what i needed and explianed in a clear way
@nima7605
@nima7605 Жыл бұрын
U have the best profile picture ever 🤣, Also thx for the Great videos
@mobbs8229
@mobbs8229 Жыл бұрын
Stevzda, thank you so much, man. Your tutorials are just so on point.
@imadbouhafer6289
@imadbouhafer6289 2 жыл бұрын
solved my 15days struggle thnx bro
@StevdzaSan
@StevdzaSan 2 жыл бұрын
Happy to help! 🙌
@shafique7z
@shafique7z 2 жыл бұрын
Man!!! I was running crazy after this! You explained well you showed an example well! you just earned a sub
@StevdzaSan
@StevdzaSan 2 жыл бұрын
Yay 🙌
@ericgacoki2225
@ericgacoki2225 3 жыл бұрын
Smart content and creative animations ❤️. We're still waiting for the Jetpack Compose 🚀 series.
@kamandemwangi
@kamandemwangi Жыл бұрын
Thank you man. I was having trouble navigating between fragments as my viewmodel was scoped to fragments instead of the activity.
@subindsuresh4897
@subindsuresh4897 2 жыл бұрын
Thank you. Explanation was very clear.
@rajaarumugam2018
@rajaarumugam2018 Жыл бұрын
Nice explanation..👍👏🥳
@samuelwakoli
@samuelwakoli 2 жыл бұрын
I like how you deliver your content. It's well understood. Thanks
@iftak01
@iftak01 3 жыл бұрын
Great video and example .. my fav one by you!
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Thanks 💜
@007ayansinha
@007ayansinha 3 жыл бұрын
useful, relevant and to the point
@ArjunVerma-lq4cf
@ArjunVerma-lq4cf 3 жыл бұрын
great explanation simple and short
@miguellugodev
@miguellugodev 3 жыл бұрын
Excellent is what i was looking for!!
@parveensharma2270
@parveensharma2270 3 жыл бұрын
Nice tutorial.....good work
@muhammadfitrie7061
@muhammadfitrie7061 2 жыл бұрын
Tq so much, as usual, very helpful
@sushmoyr
@sushmoyr 3 жыл бұрын
So, like fragments, can we use sharedViewModel in activities?
@rahmaditha4435
@rahmaditha4435 3 жыл бұрын
i have the same question as well
@MrThejaswi
@MrThejaswi 3 жыл бұрын
Technically you can by creating a custom view model factory class and returning the same instance. But this is not recommended because it defeats the purpose of view model otherwise
@iammind3888
@iammind3888 3 жыл бұрын
Awsome brother thanks for this important video
@easybusinessou
@easybusinessou 3 жыл бұрын
Amazing I always waiting for you vedio
@anudeepananth
@anudeepananth 3 жыл бұрын
Can you please do a video on how we could save the recycler view scroll positions used in fragments using the shared shared ViewModel... As of now I m hiding and showing fragments while navigating which is not an elegant solution
@odtuludenyazilim
@odtuludenyazilim 10 ай бұрын
Thank you sooooooooo much bro.
@mkc0321
@mkc0321 Жыл бұрын
awesome video, you saved me
@faboxbkn
@faboxbkn 2 жыл бұрын
amazing! nicely explained
@StevdzaSan
@StevdzaSan 2 жыл бұрын
Thanks 👍
@easybusinessou
@easybusinessou 3 жыл бұрын
I love your vedio please keep on..... 😍😍😍🙏
@amangour4508
@amangour4508 5 ай бұрын
@stevdza-San , what if a viewModel is to be shared among different activities ? how to do that ?
@earth2201
@earth2201 3 жыл бұрын
Thank you but I have a question: Why did not you create view model in Activity? And, Can I create "some" diffrence view model for "some" difference fragment? Thanks again. Sorry my bad English.
@akndonut5131
@akndonut5131 Жыл бұрын
Can we use this method share an arraylist between fragments an activitys
@StevdzaSan
@StevdzaSan Жыл бұрын
Sure
@akndonut5131
@akndonut5131 Жыл бұрын
@@StevdzaSan on my project there is a error while i wrote " private val sharedViewModel : SharedViewModel byactivityViewModels()". my pc do not recognise activityViewModels()
@coffeedude
@coffeedude 2 жыл бұрын
What do I do if I need to use a factory with the delegate activityViewModels?
@aliakkawi4759
@aliakkawi4759 3 жыл бұрын
Awesome tutorial
@kumar_rajesh_
@kumar_rajesh_ 3 жыл бұрын
can you please post a video about dagger 2 implementation it would be very helpful
@appranger6639
@appranger6639 3 жыл бұрын
One question: Can I use different viewmodels for each fragmet on top of using a shared viewmodel???? Otherwise we will have to put all the business logics of all the fragments in that same shared viewmodel. What is the solution here???
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Sure you can.
@appranger6639
@appranger6639 3 жыл бұрын
@@StevdzaSan Thank you, I was searching for this the whole day and couldn't find an answer. Because the android documentation says that we should use only one viewmodel per activity/fragment. So you are telling me I can use two viewmodels for one fragment/activity in this case, right???
@tessanix9771
@tessanix9771 Жыл бұрын
That's a great video! But I would like to know how to do the same if I use Jetpack Compose since we do not use Fragments in Compose.
@StevdzaSan
@StevdzaSan Жыл бұрын
Yeah ✅️
@tessanix9771
@tessanix9771 Жыл бұрын
@@StevdzaSan Ok but I'm only using composable so I don't have acces to "by activityViewModels()" in them. How coudl I do ?
@jayantkumar1954
@jayantkumar1954 3 жыл бұрын
It's amazing 💪💪
@Rafael-hk9pg
@Rafael-hk9pg 2 жыл бұрын
Is this possible with Jetpack Compose? Thanks!
@StevdzaSan
@StevdzaSan 2 жыл бұрын
Yep
@05Sambist
@05Sambist 3 жыл бұрын
Can you make a video about how to save fragment state at bottom navigation with Navigation Graph?
@anudeepananth
@anudeepananth 3 жыл бұрын
Yes I have the same request
@rickventura1109
@rickventura1109 3 жыл бұрын
Muito obrigado, me ajudou de mais.
@nugrohodaru9502
@nugrohodaru9502 3 жыл бұрын
Nice video 👍
@StevdzaSan
@StevdzaSan 3 жыл бұрын
🙏🙌
@Revitalish
@Revitalish 6 ай бұрын
please make a video about shared viewmodel with nested navgraphs. there are no tutorials about it
@andrzejkurowski2293
@andrzejkurowski2293 3 жыл бұрын
You're a lifesaver!
@iJuce
@iJuce 3 жыл бұрын
does Snapchat use viewpager with activities or fragments (when sliding between screens)
@sajjadabdulaziz6178
@sajjadabdulaziz6178 3 жыл бұрын
Thanks bro
@phadu1024
@phadu1024 3 жыл бұрын
Where have u inflated layout with id I cannot see that?
@henriquepetters
@henriquepetters 3 жыл бұрын
Might be stupid, but when to use vm factory? In this example you haven't used it.
@wahyukoco4562
@wahyukoco4562 2 жыл бұрын
i think it only be used if you need parameter in viewmodel
@deepakbisht7764
@deepakbisht7764 Жыл бұрын
@@wahyukoco4562 true but its better to use dependency injection. but you are right we use view model factory when we have some custom requirements and we need to do more stuffs than just creating a simple viewmodel
@KIKI-NJ
@KIKI-NJ 3 жыл бұрын
Awesome 👌 🆒️
@emmanuelg.9146
@emmanuelg.9146 3 жыл бұрын
really thank so much!!
@pratyushagarwal2000
@pratyushagarwal2000 3 жыл бұрын
Make some Content on dagger hilt
@kl3jvi
@kl3jvi 3 жыл бұрын
I fucking love you man
@nurmuhammadyuldoshev4313
@nurmuhammadyuldoshev4313 3 жыл бұрын
thanck bro
@alexanderguzman5396
@alexanderguzman5396 3 жыл бұрын
Thank you!
@StevdzaSan
@StevdzaSan 3 жыл бұрын
Always glad to help 👊
@ahmetbiyik7392
@ahmetbiyik7392 3 жыл бұрын
Video about workmanager
@hdkloh
@hdkloh 3 жыл бұрын
Thank you...
@abdellahkhalid4659
@abdellahkhalid4659 3 жыл бұрын
thank you
@anujrai5894
@anujrai5894 3 жыл бұрын
Thanks BOSS
@Sc2MooDy
@Sc2MooDy 3 жыл бұрын
Thanks!
@satyabhai4113
@satyabhai4113 3 жыл бұрын
Sticky header recyclerview. Upload tutorial please
@cw3dv
@cw3dv 3 жыл бұрын
I am always sad when I see these kind of good videos because ViewModel, DataBinding and all cannot be done by me. Why because I don't have android studio I use AIDE it does not have the capability to do that
@hannanhub1717
@hannanhub1717 3 жыл бұрын
then download android studio....
@cw3dv
@cw3dv 3 жыл бұрын
@@hannanhub1717 No computer I do android app development in an android device
@shock1136
@shock1136 Жыл бұрын
NIce video
@LazyTram911
@LazyTram911 3 жыл бұрын
CooLisimo!
@abdnezar5872
@abdnezar5872 3 жыл бұрын
great
@benjamin0mar317
@benjamin0mar317 3 жыл бұрын
👍👍👍👍
@martingelevski9509
@martingelevski9509 3 жыл бұрын
Serbia do Tokija :D
@jude-l3f
@jude-l3f 3 жыл бұрын
First
@killerHumanRabbit
@killerHumanRabbit 9 ай бұрын
thankyou so much
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 136 М.
ViewModel Explained - Android Architecture Component | Tutorial
8:27
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
The ViewModel & LiveData Tutorial in Android Studio (Kotlin)
8:56
THIS Compose-State Mistake Leads to Problems In Your Code
7:58
Philipp Lackner
Рет қаралды 46 М.
LiveData Explained - Android Architecture Component | Tutorial
12:12
2024's Biggest Breakthroughs in Math
15:13
Quanta Magazine
Рет қаралды 356 М.
6 Design Patterns Every Android Developer Must Know
14:16
Philipp Lackner
Рет қаралды 83 М.
Android. SurfaceView. Рисуем звезды в 3D, теперь на телефоне.
32:58
I built a REAL Desktop App with both Tauri and Electron
12:22
Bufferhead
Рет қаралды 71 М.
Advanced layout animations in Compose (Shared elements)
30:33
Android Developers
Рет қаралды 23 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН