当触摸到某些控件时候 隐藏输入法键盘

来源:互联网 发布:美橙互联域名证书下载 编辑:程序博客网 时间:2024/05/16 06:41

当触摸到某些控件时候 隐藏输入法键盘

linearLayout.setOnTouchListener(this); @Override    public boolean onTouch(View view, MotionEvent motionEvent) {        if (view == linearLayout && motionEvent.getAction()== MotionEvent.ACTION_DOWN){            //隐藏软键盘            InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);            View focusedView = getCurrentFocus();            if(focusedView!=null && focusedView.getWindowToken()!=null){                manager.hideSoftInputFromWindow(focusedView.getWindowToken(), 0);            }        }        return true;    }
0 0
原创粉丝点击