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 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
@@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)
@Dark Sigma Yes you can, and remember to use the double bang '!!' operator whenever referencing like binding!!.tvHelloWorld.text = "View Binding in Fragments"
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!
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.
@@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.
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.
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
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 :)
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?
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?
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
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?
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.
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
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
How can I use view binding with base activity? In my application all activities extends a common Base activity where all common functionalities written.
Sadly getting an error if i follow your instruction: "Function invocation 'LayoutInflater(...)' expected" (line: "binding = ActivityMainBinding.inflate(LayoutInflater)"). Could you help please?
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).
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 ! 😂😂
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 UA-cam as of now .
@@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
@@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 =)
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
@@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!!
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
Hey Phillip great video, can you please explain why do we need to destroy the binding?
@@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
@@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)
@Dark Sigma Yes you can, and remember to use the double bang '!!' operator whenever referencing like
binding!!.tvHelloWorld.text = "View Binding in Fragments"
@@samirbasnet9523 you destroy the binding to prevent potential data leakage
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!
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.
I love your tutorials i set a plan with my self to watch all of your tutorials from the beginning to the end.
Good plan, thanks!
@@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.
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.
Way way difficult man
@@Chinez How has your progress been man
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.
Man u saved the life of a new android developper
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
Thank you! Your english is so simple, i understand around 60-70% of text. It`s great for me!
Awesome video, so well explained, thank you as always dude!
My pleasure!
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 :)
Great job my german mate. You help my a lot!
Danke 💪
i miss your intros with that hardcore music
I'm not ready to move from kotlin synthetics😭
Btw Thank you for this video.
and now ;)
@@ahmad7a.4k28 ;)
kotlin synthetic is emotion
you saved me
Thanks for short and right to point video
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?
Thanks for the tutorial, then why we use android-kotlin-extensions? What's the difference between the two? which way is better?
Thank you once again. Straight to the point
Why are viewbinding not included in the default projects?
wondering too..
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.
Only in the projects, not in these single tutorial, that just takes too long to setup everytime if I just make a 10min video
@@PhilippLackner Yes, that was I mean to say and forgot to specify it.
Congratulations for 10 k subscribers
Thank you so much 😀
Very simple! you're awesome. Thanks.
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?
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.
awesome tutorial. you make it easy to understand
You literally solved a weekend of headaches in 8 minutes
Hey Philip Thank you very and so much for this video
Perfect explanation 👌
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?
What's your opinion on DataBinding? is it recommended? i don't see you using it in your tutorials
Don't I need to add in XML, or is it required only while using data binding?
Only for data binding
@@PhilippLackner cool. Thanks
It's been a while since I saw one of your videos and holy fuck that beard looks awesome.
Thanks 😂
Great explained :D
underrated channel your content✌
Great Tutorial Philipp
How can we use view reference while writing android test, Is there any way to mock view-binding
Which is better to use? viewbinding or Kotlin synthetics?
If I need to access a layout in a different module, does ViewBinding still work?
yes
and by that class name you've to create a new inflator
Great effort bro. Keep it up.
Thank you, I will
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
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
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 ?
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?
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.
hey we can use the kotlin extensions also... why binding is better here?
didn't I explain that in the video? :D
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
i like this video, God bless you
Thanks, but idk why i needed to build graddle many times to be able to lateinit the binding
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
This video is old, but useful
thanks bro finally I understand
How can I use view binding with base activity? In my application all activities extends a common Base activity where all common functionalities written.
I'm now scared to update Android studio because Synthetic Binding got removed from new Android Studio version.
How about letting the App run for an example?
Sadly getting an error if i follow your instruction: "Function invocation 'LayoutInflater(...)' expected" (line: "binding = ActivityMainBinding.inflate(LayoutInflater)"). Could you help please?
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).
Thanku so much ❤️
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 ! 😂😂
Who can't write my name properly doesn't deserve my premium courses 😂
15th? He's 15?
@@arpitgupta3151 LOL hes in his early 20s.
Hey great tutorial 💓
Thank you! 😊
How to use ViewBinding in BaseActivity class which has its own Ui in activity_base.xml? and how to access these views in BaseActivity?
loved the video
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 UA-cam as of now .
I have an entire playlist about exoplayer to make a full music streaming player
@@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
Really amazing
Very nice video
Why do we put the layout inside the fragment constructor?
Fastest way to set the layout
Thank you!
How can we use viewBinding if we have BaseFragment or BaseActivity ?
sure
Thank you
thanks you so muck
How would the viewBinding for the adapter look, would anyone know?
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
@@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 =)
thanks alot
You forgot to destroy the binding..This prevents memory leaks
You are right, sorry for that
best video
Thanks a lot
hi i am new to android can anyone tell me how to destroy the binding like can you give me the code pls
I trust you man
Epic!
Interesting!
It seems that this
buildFeatures {
viewBinding true
}
Is replaced with
viewBinding {
enabled true
}
i think viewBinding is from android studio version 3.6 and higher.....buildFeatures is 4.0 and higher
thank youu
thanks
7:36 FragmentTestBinding is not showing
Interested theme )
I wish someone would make a 3rd party synthetics alternative much cleaner than this.
viewbinding is throwing error in inflating ActivityMainBinding
did you solve it?
@@gurthang061 yes
nice :)
Thank Philipp very clear!
but, fuck them I'm staying with synthetics for as long as I can -.-"
Where we are with Android dev: Learning something new that we know is soon to be deprecated 😅
#jetpackcompose
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
@@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!!
can you teach me how to interpret smali code?
One more reason to name views' id in java convention
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
😀
ربي يزوجك
#mTV :
Synthetics is pronounced: Sin-theh-ticks. Not Sint-het-icks.
Too much talking and not enough showing.
thank you