@Override public void onAttachedToWindow() { super.onAttachedToWindow(); WindowId token = getWindow().getDecorView().getWindowId(); token.registerFocusObserver(mObserver); mState.setText(token.isFocused() ? "Focused" : "Not focused"); }
@Override public void onFocusGained(WindowId token) { mState.setText("Gained focus"); }
@Override public void onFocusLost(WindowId token) { mState.setText("Lost focus"); }