Hello Friends View Binding is new features available for android developer with updated Android Studio version.
It simply replace code of findViewById() means no need to write code of finding each view individually view binding automatically gets reference from respective layout.
We also have published video on you tube you can also watch this video.
- To enable view binding in the android application you need to write the following code inside module-level Gradle file of your application
2) After enable viewBinding binding class respective to your layout file will autogenerated
- For Example I create MainActivity with layout file activity_main then binding class name will be ActivityMainBinding because layout file name activity_main
- So inside java file of Activity we can write
3) Here I have code inside my layout file
4) finally inside MainActivity.java file we can get reference of all views easily as below
View Binding in Fragments
View Binding if you want to implement inside fragments then here is the code sample
So Friends I hope you get the concept of View Binding So I personally prefer View Binding in my every application
If you still have any doubt please write comment here I will solve your doubt you can also watch you tube video I have attached.