@Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { if (gainFocus == true) { } else { } } super.onFocusChanged(gainFocus, direction,previouslyFocusedRect);
重写这个方法,但要注意一点的是把这个View setFocusableInTouchMode(true)或者setFocuseable(true),不然可能会不成功