instead of findViewbyId
# android
v
instead of findViewbyId
s
On Slack you can edit the previous message instead of going full auto mode 😌 You can use View Binding to bind you view's layout.
findViewById
return a generic of type
View
so
val button: Button = findViewById(...)
or
val button = findViewById<Button>(...)
will provide you a
Button
(or crash at runtime if it's not a button). On the other hand View Binding (starting AGP 3.6) are type-safe, null safe (ex: a view present in a layout configuration and absent in another configuration).
v
@satyan thank you!