public void dismissSoftInput() { // 隐藏软键盘 InputMethodManager imm = ((InputMethodManager) mContext.getSystemService(Activity.INPUT_METHOD_SERVICE)); if (mContext.getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (mContext.getCurrentFocus() != null) imm.hideSoftInputFromWindow( mContext.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
private void showSoftInput() { if (mContext.getWindow().getAttributes().softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (mContext.getCurrentFocus() != null) { InputMethodManager imm = ((InputMethodManager) mContext.getSystemService(Activity.INPUT_METHOD_SERVICE)); imm.showSoftInputFromInputMethod(mChatView.getWindowToken(), 0); } } }