Reputation: 3557
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?
Upvotes: 17
Views: 13432
Reputation: 12953
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.
Upvotes: 28
Reputation: 91
This should explain a bit about it
Sometimes views in Android are grouped together, and if one of the views in that group has focus, the hasFocus()
method will return true
, but only when the specific view you are mentioning in code is focused will isFocused()
equal true
.
Upvotes: 7