Hi guys, I'm studying android + kotlin in google U...
# android
s
Hi guys, I'm studying android + kotlin in google Udacity course and in the course say that for performance improvement we shouldn't use a lot findViewById when you can store the view in a field. My question is, AndroidX adds a way better to get views just putting the name of it and using, internally this property calls findViewById ? I should store this view too using AndroidX ?
n
Yes, internally the synthetic accessors cache the result from findViewById. There is typically no need to store it separately in your code. In our project, we've switched to using DataBinding instead of synthetic accessors after following this discussion: https://proandroiddev.com/the-argument-over-kotlin-synthetics-735305dd4ed0
👍 5
s
Thank you
🙃 1
d
Unfortunately, in some cases DataBinding can be overkill and can bring more issues because of it's codegen nature. On the latests I/O some kind of view binding was announced for those who use
DataBinding
only instead of
findViewById
but I can't find information about it now.
👍 2
l