https://kotlinlang.org logo
#android
Title
# android
l

Leandro Ocampo

10/19/2020, 10:49 AM
Hey guys... is it safe to use
Copy code
val someView by lazy { findViewById(R.id.some_view) }
? My concern is can happen that an Activity / Fragment may need to recreate (inflate again) the view but being the same object? Let's say onCreate (activity) or onCreateView (fragment) is called again for the same object I think it is safe to do this in an activity, but I do not think so for Fragments 🤔
g

gildor

10/19/2020, 11:19 AM
Yes, it's unsafe for current implementation of fragments
45 Views