Kotlin has a number of Android Extensions and one ...
# android
Kotlin has a number of Android Extensions and one of them is that by referencing the ID of the view findViewById method is not necessary. And it is actually using cache so when you access that same view it is taken from cache. This works for Activity and Fragment classes, but when referencing a view by its ID from a custom class such as ViewHolder there is no cache and for every view in RecyclerView findViewById is called, so in that case I need to implement LayoutContainer interface on that class. So my question is, is this implementation still necessary in late 2019?
👌 1
In fact, the View cache of
Kotlin Android Extensions
have some known flaws and is expected to be replaced by the upcoming
. I personally don't mind using
in a ViewHolder.
Unless your view hierarchy is massive don’t bother with a cache. You should indeed look at ViewBinding instead.