06/09/2020, 7:47 PM
How important is Viewbinding to Activity? Since i can make reference to my widgets just by importing the layout. I think Binding works better for Fragments. Any opinions ?

Olenyov Kirill

06/09/2020, 8:37 PM
No difference. It also gives you null and types safe both for activities and fragments.


06/09/2020, 8:38 PM
ViewBinding is always superior to Kotlin Synthetics
burn databinding, burn synthetics
😂 2


06/09/2020, 9:23 PM
@zhuinden How ?
I think ViewBinding is cool for working with Fragments. BBut for Activity, its just an alternative of having a collection of all widget in one place. Where you can access easily. Just like Java and Kotlin.

Mark Murphy

06/09/2020, 9:28 PM
its just an alternative of having a collection of all widget in one place
If by "alternative" you mean "alternative to Kotlin synthetic accessors", I'm in agreement with Gabor: use view binding. Quoting myself from a book:
The larger the project, though, the greater the risk is that you will use the wrong imports. Once you start getting dozens or hundreds of layout resources, making sure that you use the right imports starts to become a challenge. The compiler will be very happy to let you use any import you want. However, if you try referencing a widget from Layout X and you are really using Layout Y, it is likely that you will wind up crashing with a
somewhere along the line.
For a minor amount of setup overhead (a few lines in a Gradle script and a couple of lines per activity, fragment, etc.), you get the code-generated guarantee that you are referencing widgets that exist.
❤️ 2


06/09/2020, 9:38 PM
Thats the use case.

Anastasia Finogenova

06/10/2020, 2:15 AM
And in the concept of single activity all you have is fragments 🤷