I need to find out if any view inside the Activity is focused and what kind of view it is. How to do it?
Call getCurrentFocus() in the Activity.
getCurrentFocus()
From the source of activity:
/** * Calls {@link android.view.Window#getCurrentFocus} on the * Window of this Activity to return the currently focused view. * * @return View The current View with focus or null. * * @see #getWindow * @see android.view.Window#getCurrentFocus */ public View getCurrentFocus() { return mWindow != null ? mWindow.getCurrentFocus() : null; }
for any reason, the getCurrentFocus () method is not available; probably it is already outdated, here is a working alternative:
View focusedView = (View) yourParentView.getFocusedChild();