Тёмный

Android ViewBinding in 8 Minutes 

Philipp Lackner
Подписаться 180 тыс.
Просмотров 77 тыс.
50% 1

This video teaches you everything you need to know about ViewBinding in Android.
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/...
Regular Android tutorials on my Instagram: / _philipplackner_
Checkout my GitHub: github.com/phi...

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

 

6 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 151   
@PhilippLackner
@PhilippLackner 3 года назад
I forgot to mention in this video that you should also destroy your binding in the onDestroy() function. For that, simply make it nullable and set it to null in onDestroy
@samirbasnet9523
@samirbasnet9523 3 года назад
Hey Phillip great video, can you please explain why do we need to destroy the binding?
@derpizzaboi
@derpizzaboi 3 года назад
@@samirbasnet9523 i am not 100% shure, but i think the problem is that if you rotate your device, the view gets destroyed. if your rotated view is the same as the one before you dont have a problem. But if you have two diffrent views for portrait and landscape mode, you will get a null pointer exception because the view that is still stored in the binding variable is not on the screen anymore
@nousernamethx
@nousernamethx 3 года назад
@@samirbasnet9523 Fragments outlive their views. Make sure you clean up any references to the binding class instance in the fragment's onDestroyView() method.(taken from developers.android site)
@pratikmaurya7394
@pratikmaurya7394 3 года назад
@Dark Sigma Yes you can, and remember to use the double bang '!!' operator whenever referencing like binding!!.tvHelloWorld.text = "View Binding in Fragments"
@aghoghoakpedeye6396
@aghoghoakpedeye6396 2 года назад
@@samirbasnet9523 you destroy the binding to prevent potential data leakage
@amoliski
@amoliski 3 года назад
Wow, 3 minutes at 2x speed took care of every confusion I had after spending multiple hours in the official docs trying to figure this stuff out. Thanks!
@joegracey
@joegracey 2 года назад
I'm trying to learn Android development with Kotlin so thank you for this! Also, app dev is very difficult; way more than I thought it would be.
@Chinez
@Chinez 2 года назад
Way way difficult man
@MisterWealth
@MisterWealth Год назад
@@Chinez How has your progress been man
@jimlthor
@jimlthor Год назад
Funny how crazy it is. I know python, some java and C++ and have dabbled in Unreal Engine.. As simple as these apps look to a user, this shit is ridiculous.
@peyvandjadidi4395
@peyvandjadidi4395 3 года назад
thank you so much for this helpful video , i've been searching for 4 hours to learn viewBiniding but non of those i found were as simple and helpful as yours.
@m1eayoub152
@m1eayoub152 2 года назад
Man u saved the life of a new android developper
@user-dh8ui5hy7g
@user-dh8ui5hy7g 3 года назад
I love your tutorials i set a plan with my self to watch all of your tutorials from the beginning to the end.
@PhilippLackner
@PhilippLackner 3 года назад
Good plan, thanks!
@user-dh8ui5hy7g
@user-dh8ui5hy7g 3 года назад
@@PhilippLacknerI checked your website you are genius, i will watch them all on your website because it allows us to learn step by step i mean it's more organized.
@user-gi4no6gn7m
@user-gi4no6gn7m 3 года назад
I'm not ready to move from kotlin synthetics😭 Btw Thank you for this video.
@ahmad7a.4k28
@ahmad7a.4k28 3 года назад
and now ;)
@user-gi4no6gn7m
@user-gi4no6gn7m 3 года назад
@@ahmad7a.4k28 ;)
@shaikhnabeel6443
@shaikhnabeel6443 3 года назад
kotlin synthetic is emotion
@ronniepedersen4367
@ronniepedersen4367 3 года назад
Why are viewbinding not included in the default projects?
@Lyrics-bi8ig
@Lyrics-bi8ig Год назад
wondering too..
@VoidObj
@VoidObj 3 года назад
Thank you! Your english is so simple, i understand around 60-70% of text. It`s great for me!
@IceInMaWeiner
@IceInMaWeiner 2 года назад
Awesome tutorial with examples, I wish more tutorials would add Kotlin/Java in the title though. Haven't started learning Kotlin yet but still a good watch to understand the flow of binding
@parthpatel8173
@parthpatel8173 3 года назад
Personal Suggestion: Please use ViewBinding & DataBinding in your upcoming tutorials. So, it will be more clear to how can we use it in real projects.
@PhilippLackner
@PhilippLackner 3 года назад
Only in the projects, not in these single tutorial, that just takes too long to setup everytime if I just make a 10min video
@parthpatel8173
@parthpatel8173 3 года назад
@@PhilippLackner Yes, that was I mean to say and forgot to specify it.
@raghavaggarwal8644
@raghavaggarwal8644 3 года назад
Thanks for the tutorial, then why we use android-kotlin-extensions? What's the difference between the two? which way is better?
@marcel5235
@marcel5235 3 года назад
short helpful with fragments, liked subscribed, btw I do your fundamentals course on your web, very clean and relatively in date so it replaced the whole book I had about that. Keep going and If you will have some more advanced courses like Spotify clone and rest of them in future, hell even if they will be paid I will sign for them. You do a really great job to spread your knowledge and KUDOS to you :)
@BenKadel
@BenKadel 3 года назад
Awesome video, so well explained, thank you as always dude!
@PhilippLackner
@PhilippLackner 3 года назад
My pleasure!
@yanikhohner374
@yanikhohner374 3 года назад
Great job my german mate. You help my a lot!
@PhilippLackner
@PhilippLackner 3 года назад
Danke 💪
@xD-saleem
@xD-saleem 3 года назад
i miss your intros with that hardcore music
@_sharmaji.dev_
@_sharmaji.dev_ 3 года назад
you saved me Thanks for short and right to point video
@brianquigley1940
@brianquigley1940 3 месяца назад
So... "binding" puts the physical address of a variable/view (their location in memory) in a variable? You then reference that area of memory? Or reference an offset to a part of that location in memor? e.g. root points to the base address and a textview points to its offset from that base address. Did I get this right?
@aginamabednego
@aginamabednego 2 года назад
Thank you once again. Straight to the point
@andressarebecapinheiro8061
@andressarebecapinheiro8061 2 года назад
Hey, thank you for the video and your time! How do you record your face with the content on the background? Which program and tools do you use?
@devanshmaurya9928
@devanshmaurya9928 3 года назад
It seems that this buildFeatures { viewBinding true } Is replaced with viewBinding { enabled true }
@sonnysarcia6947
@sonnysarcia6947 3 года назад
i think viewBinding is from android studio version 3.6 and higher.....buildFeatures is 4.0 and higher
@workwithray2569
@workwithray2569 3 года назад
You literally solved a weekend of headaches in 8 minutes
@footballCartoon91
@footballCartoon91 18 дней назад
This video is old, but useful
@moriz8549
@moriz8549 3 года назад
awesome tutorial. you make it easy to understand
@axelasa277
@axelasa277 3 года назад
Ah, my man decided to grow his beared, awesome. DO you have a video on MVVM? for some reason I find you easy to understand.
@technics6215
@technics6215 Год назад
My Android Studio (in 2022), when I added new activity with navigation drawer created "private FragmentSomethingBinding binding;" for me, but it is without lateinit modifier. Something changed since 2020 when this tutorial was made?
@YukoshiHub
@YukoshiHub 3 года назад
Very simple! you're awesome. Thanks.
@yusufmiftahudeen
@yusufmiftahudeen 10 месяцев назад
i like this video, God bless you
@Meru-pv9uj
@Meru-pv9uj 11 месяцев назад
Thanks, but idk why i needed to build graddle many times to be able to lateinit the binding
@ShepherdSani
@ShepherdSani 3 года назад
Hey Philip Thank you very and so much for this video
@guitarbansi1
@guitarbansi1 3 года назад
If I need to access a layout in a different module, does ViewBinding still work?
@easelogic
@easelogic 3 года назад
yes
@easelogic
@easelogic 3 года назад
and by that class name you've to create a new inflator
@amtrax02
@amtrax02 3 года назад
Great explained :D
@riddhishah7708
@riddhishah7708 10 месяцев назад
Perfect explanation 👌
@MDDanishAnsariDev
@MDDanishAnsariDev 3 года назад
Don't I need to add in XML, or is it required only while using data binding?
@PhilippLackner
@PhilippLackner 3 года назад
Only for data binding
@MDDanishAnsariDev
@MDDanishAnsariDev 3 года назад
@@PhilippLackner cool. Thanks
@lokesharora8638
@lokesharora8638 2 года назад
thanks bro finally I understand
@imnithish
@imnithish 3 года назад
I'm now scared to update Android studio because Synthetic Binding got removed from new Android Studio version.
@yossimaskin1393
@yossimaskin1393 2 года назад
What's your opinion on DataBinding? is it recommended? i don't see you using it in your tutorials
@sodaguy5835
@sodaguy5835 3 года назад
underrated channel your content✌
@miq0717
@miq0717 3 года назад
Which is better to use? viewbinding or Kotlin synthetics?
@daiyrkanybekov8575
@daiyrkanybekov8575 3 года назад
Great Tutorial Philipp
@kipbena8224
@kipbena8224 3 года назад
You forgot to destroy the binding..This prevents memory leaks
@PhilippLackner
@PhilippLackner 3 года назад
You are right, sorry for that
@salarydost8147
@salarydost8147 3 года назад
Congratulations for 10 k subscribers
@PhilippLackner
@PhilippLackner 3 года назад
Thank you so much 😀
@victor-ioncislari2375
@victor-ioncislari2375 2 года назад
How about letting the App run for an example?
@jafartemirov7812
@jafartemirov7812 3 года назад
hi bro, Your tutorail is really good, there is no words to describe actually, Could you make video about Databinding and more advanced tutorail maybe kind of ecommerce app
@PhilippLackner
@PhilippLackner 3 года назад
Thanks, for more advanced tutorials checkout the courses on pl-coding.com :) Within the next week I'll publish a course about a social network there
@AmitVerma-iq3oe
@AmitVerma-iq3oe Год назад
How can we use view reference while writing android test, Is there any way to mock view-binding
@arulraj011988
@arulraj011988 3 года назад
How can I use view binding with base activity? In my application all activities extends a common Base activity where all common functionalities written.
@amanchaudhary8627
@amanchaudhary8627 Год назад
Thanku so much ❤️
@ulricha.abiguime7918
@ulricha.abiguime7918 Год назад
loved the video
@nomanzafarzafar7912
@nomanzafarzafar7912 3 года назад
Great effort bro. Keep it up.
@PhilippLackner
@PhilippLackner 3 года назад
Thank you, I will
@mehulbisht9708
@mehulbisht9708 3 года назад
8:23 Reality - Philipp : use code Philipp15 for 15% discount. Kids : trying to use the code but failing because : Philip15 Phillip15 Phillipp15 Legends : Happy 15th Birthday Philipp ! 😂😂
@PhilippLackner
@PhilippLackner 3 года назад
Who can't write my name properly doesn't deserve my premium courses 😂
@arpitgupta3151
@arpitgupta3151 3 года назад
15th? He's 15?
@xD-saleem
@xD-saleem 3 года назад
@@arpitgupta3151 LOL hes in his early 20s.
@thearpansircar
@thearpansircar 3 года назад
It's been a while since I saw one of your videos and holy fuck that beard looks awesome.
@PhilippLackner
@PhilippLackner 3 года назад
Thanks 😂
@TheAbhidugar
@TheAbhidugar 3 года назад
I used view binding. Also I used custom theme in manifest file to hide ActionBar in main activity only. But either it was giving InflateException or showing blank on phone when experimenting to make it work. I, then, removed view binding and used same old setcontentview(R.layout.activity_main) and IT WORKED. What am I be doing wrong using view binding? Can you please tell? and thanks for the video.
@h.r.60
@h.r.60 3 года назад
i'm having issues with using my own custom library. I publish it to github but when i implement it in the build.gradle, my android studio doesn't allow me to call any of my library's classes. any suggestions?
@aekazakgmail
@aekazakgmail 3 года назад
Thank you Philipp! Nice to see your face in video! Great style! I don’t like this new coding style with binding.textview1.... binding.button1... binding.whateverElse... Looks like as everything I can see is binding binding binding )) It drives me mad a little bit. So I renamed ‘binding’ class to just ‘b’. Works fine! Now I can see in my code: b.textview1.... b.button1... b.whateverElse... Looks much better for me! Keep it going, Philipp!
@sidharthmanoj3343
@sidharthmanoj3343 2 года назад
Why does the package name of the generated binding class have "databinding" in it ? Does this mean that view binding is a part of data binding ?
@codingwithsam4992
@codingwithsam4992 2 года назад
Thank you
@yutaitadori7318
@yutaitadori7318 3 года назад
Hey great tutorial 💓
@PhilippLackner
@PhilippLackner 3 года назад
Thank you! 😊
@spacegyaan2171
@spacegyaan2171 3 года назад
hey we can use the kotlin extensions also... why binding is better here?
@PhilippLackner
@PhilippLackner 3 года назад
didn't I explain that in the video? :D
@murml
@murml 3 года назад
Sadly getting an error if i follow your instruction: "Function invocation 'LayoutInflater(...)' expected" (line: "binding = ActivityMainBinding.inflate(LayoutInflater)"). Could you help please?
@murml
@murml 3 года назад
Found the problem: there seems to be a difference between LayoutInflater and layoutInflater (upper/lower case - lower works, if someone else got the same problem).
@ferrianrp
@ferrianrp 3 года назад
Hi, i wan't to ask something. I used viewbinding inside fragment. And i have process like this, from activity A -> Activity B (Fragment A) and then i finished activity B. There is some error null Viewbinding when i go back to Activity B(Fragment A) and do some process. I don't know what happen. Can you give me a solution? thanks
@vidakamalifar7459
@vidakamalifar7459 3 года назад
Hello, I have a question : When I want to import ActivityMainBinding is imported with: import com.dagger.hilt.databinding.ActivityMainBinding Then I got this error in compile: error: [Hilt] androidx.core.app.ActivityCompat, expected to be annotated with @DefineComponent. Found: [Hilt] What is wrong? I did the code step by step with you
@jishnunkrishnan5783
@jishnunkrishnan5783 3 года назад
Thank you!
@siddharthagrawal6157
@siddharthagrawal6157 3 года назад
Really amazing
@AnhNguyen-qd8cm
@AnhNguyen-qd8cm 3 года назад
thanks you so muck
@MCStarYT
@MCStarYT 3 года назад
Very nice video
@gauravthakkar802
@gauravthakkar802 3 года назад
Why do we put the layout inside the fragment constructor?
@PhilippLackner
@PhilippLackner 3 года назад
Fastest way to set the layout
@androidterminal3924
@androidterminal3924 2 года назад
best video
@mdjahidulislam9205
@mdjahidulislam9205 3 года назад
Thanks a lot
@syedfilms4447
@syedfilms4447 2 года назад
thanks alot
@odh_konkanchi
@odh_konkanchi 3 года назад
How to use ViewBinding in BaseActivity class which has its own Ui in activity_base.xml? and how to access these views in BaseActivity?
@kadrsnr
@kadrsnr 2 года назад
thank youu
@MtaufiqH731
@MtaufiqH731 3 года назад
Interesting!
@yahyafati
@yahyafati 3 года назад
I trust you man
@chiragprajapati3989
@chiragprajapati3989 3 года назад
How can we use viewBinding if we have BaseFragment or BaseActivity ?
@PhilippLackner
@PhilippLackner 3 года назад
sure
@user-nz6vg1vn5u
@user-nz6vg1vn5u 3 года назад
thanks
@tusharhatwar4374
@tusharhatwar4374 3 года назад
I know this is not right place to request you but can you please make one video on mediaplayer to read multiple song from URL and play using mediaplayer only in kotlin? There is known video tutorial available on RU-vid as of now .
@PhilippLackner
@PhilippLackner 3 года назад
I have an entire playlist about exoplayer to make a full music streaming player
@tusharhatwar4374
@tusharhatwar4374 3 года назад
@@PhilippLackner yes I know but i don't want using any other library I want using mediaplayer .....I have also commented on that video playlist for same request
@arpitgupta3151
@arpitgupta3151 3 года назад
7:36 FragmentTestBinding is not showing
@shreyashchoudhary7413
@shreyashchoudhary7413 3 года назад
Epic!
@user-mz1qg6td2e
@user-mz1qg6td2e 7 месяцев назад
hi i am new to android can anyone tell me how to destroy the binding like can you give me the code pls
@dreamer6228751
@dreamer6228751 3 года назад
Interested theme )
@mustafashaikh7829
@mustafashaikh7829 3 года назад
nice :)
@leonidas_30052
@leonidas_30052 3 года назад
How would the viewBinding for the adapter look, would anyone know?
@PhilippLackner
@PhilippLackner 3 года назад
The same way you do it else where. Instead of a view you pass the binding in your viewholder and then you inflate it in with the binding instead
@leonidas_30052
@leonidas_30052 3 года назад
@@PhilippLackner That's right, I thought there was something else, but I tried the implementation yesterday and everything went well. Thanks Philipe, you are a thousand =)
@kamaldubey3382
@kamaldubey3382 Год назад
viewbinding is throwing error in inflating ActivityMainBinding
@gurthang061
@gurthang061 Год назад
did you solve it?
@kamaldubey3382
@kamaldubey3382 Год назад
@@gurthang061 yes
@TZCoder
@TZCoder 3 года назад
I wish someone would make a 3rd party synthetics alternative much cleaner than this.
@MateusMeurer
@MateusMeurer 3 года назад
Thank Philipp very clear! but, fuck them I'm staying with synthetics for as long as I can -.-"
@jonplaud
@jonplaud 3 года назад
Android better make updates, I thought something was wrong with my program. I am trying to get my Android cert and this came up. #Frustrated
@ofoefulechristian9684
@ofoefulechristian9684 3 года назад
Where we are with Android dev: Learning something new that we know is soon to be deprecated 😅 #jetpackcompose
@PhilippLackner
@PhilippLackner 3 года назад
Just because jetpack compose will be out doesn't mean you don't need to understand XML. There will be SO MUCH legacy code in the internet and especially companies can't just casually switch to compose if they have big apps using XML. Also, it'll take some time till compose is stable and not in alpha anymore
@ofoefulechristian9684
@ofoefulechristian9684 3 года назад
@@PhilippLackner I totally agree. Its just that sometimes it's overwhelming to keep-up with so many changes. I'm currently using ViewBinding in some projects too and its super cool! Thanks for been awesome!!
@ojiidroid
@ojiidroid 3 года назад
can you teach me how to interpret smali code?
@mohdz4217
@mohdz4217 5 месяцев назад
ربي يزوجك
@ajaygalagali5963
@ajaygalagali5963 3 года назад
😀
@feepin2058
@feepin2058 3 года назад
One more reason to name views' id in java convention
@johnkline4350
@johnkline4350 2 года назад
Synthetics is pronounced: Sin-theh-ticks. Not Sint-het-icks.
@username-dh4tq
@username-dh4tq 2 года назад
#mTV :
@jeffh.8127
@jeffh.8127 2 года назад
Too much talking and not enough showing.
@miyamoto856
@miyamoto856 2 года назад
thank you
Далее
TOASTS AND CONTEXT - Android Fundamentals
16:51
Просмотров 37 тыс.
Let, Also, Apply, Run, With - Kotlin Scope Functions
11:44
FRAGMENTS - Android Fundamentals
17:29
Просмотров 329 тыс.
Make Your Code Clean With the SOLID Principles
18:24
Просмотров 98 тыс.