I understand the difference among focused, selected and pressed. But I don't understand the difference between hasFocus()
and isFocused()
. I checked the description, both descriptions say almost the same thing. Can anyone please explain this to me?
The View. isFocused() method tells whether the view in question is focused or not. Or else, you can compare your views by id. @CGR Well, isFocused() is the preferred way to go here.
Focusable means that it can gain the focus from an input device like a keyboard. Input devices like keyboards cannot decide which view to send its input events to based on the inputs itself, so they send them to the view that has focus.
hasFocus()
is different from isFocused()
. hasFocus() == true
means that the
View or one of its descendants is focused. If you look closely,
there's a chain of hasFocused Views till you reach the View that
isFocused.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With