android force - How to find out which view is focused?




3 Answers

Call getCurrentFocus() on the Activity.

lifecycle xml

I need to find out if any view is focused inside an Activity and what view it is. How to do this?




for some reason getCurrentFocus() method isn't available anymore; probably it's deprecated already, here the working alternative:

View focusedView = (View) yourParentView.getFocusedChild();



if you are in a fragment you can use

getView().findFocus()



Related


Tags

android