点击键盘外,让软键盘消失

 

这个操作还是很有必要滴,,笔记也是得做滴

@Override
public boolean onTouchEvent(MotionEvent event) {
    InputMethodManager manager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    // TODO Auto-generated method stub
    if(event.getAction() == MotionEvent.ACTION_DOWN){
        if(getCurrentFocus()!=null && getCurrentFocus().getWindowToken()!=null){
            manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
    return super.onTouchEvent(event);
}

 

posted @ 2016-06-14 11:21  北宫风晨  阅读(308)  评论(0编辑  收藏  举报