android 隐藏软键盘的函数

2021-03-12  本文已影响0人  呼语

函数体

/**
     * hide soft keyboard
     * @param token
     */
    private void hideSoftKeyBoard(IBinder token , Context context) {
        if (token != null) {
            InputMethodManager im = (InputMethodManager)  context.getSystemService(Context.INPUT_METHOD_SERVICE);
            im.hideSoftInputFromWindow(token,
                    InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }

调用方法


hideSoftKeyBoard(view.getWindowToken() , view.getContext());   //view为焦点所在的控件

上一篇 下一篇

猜你喜欢

热点阅读