Monthly Archives: September 2017

Gotcha: Android O and View.hasFocusable()

Are you using or overridingĀ View.hasFocusable() in your application? Watch out for behavior changes in Android O and a newly added View.hasExplicitFocusable(). The behavior of hasFocusable() will change depending on whether you are targeting SDK 26, or an older version, while hasExplicitFocusable() maintains the pre-O behavior of hasFocusable(), regardless of the SDK version that you are targeting.

If you are overriding hasFocusable(), know that some framework locations that used to call hasFocusable() have been changed to call hasExplicitFocusable() instead. In particular, AbsListView‘s touch handling code now uses hasExplicitFocusable() to determine whether or not to execute the onItemClick() function, or to delegate the click to the child view within the list.