android View根据自己获取焦点的情况执行语句

@Override 
protected void onFocusChanged(boolean gainFocus, int direction, 
                                  Rect previouslyFocusedRect) 
    { 
        if (gainFocus == true) 
        { 
     
        } 
        else 
        { 
            
        } 
    } 
          super.onFocusChanged(gainFocus, direction,
previouslyFocusedRect);   


重写这个方法,但要注意一点的是把这个View setFocusableInTouchMode(true)或者setFocuseable(true),不然可能会不成功

猜你喜欢

转载自luozheng216.iteye.com/blog/1673910
今日推荐