ViewBinding - Forget about findViewById | Android Studio Tutorial

Published: 22 March 2020
on channel: Stevdza-San
24,614
691

🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN
https://stevdza-san.com

🐱‍👤 Wanna become a member? Join!
   / @stevdzasan  

📸 Instagram
  / stevdza_san  


View binding is a feature that allows you to more easily write code that interacts with views. Once view binding is enabled in a module, it generates a binding class for each XML layout file present in that module. An instance of a binding class contains direct references to all views that have an ID in the corresponding layout. In most cases, view binding replaces findViewById.

View binding has important advantages over using findViewById:

*** Null safety: Since view binding creates direct references to views, there's no risk of a null pointer exception due to an invalid view ID. Additionally, when a view is only present in some configurations of a layout, the field containing its reference in the binding class is marked with @Nullable.
*** Type safety: The fields in each binding class have types matching the views they reference in the XML file. This means that there's no risk of a class cast exception.


On this page of the site you can watch the video online ViewBinding - Forget about findViewById | Android Studio Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Stevdza-San 22 March 2020, share the link with friends and acquaintances, this video has already been watched 24,614 times on youtube and it was liked by 691 viewers. Enjoy your viewing!