显示软键盘:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
隐藏软键盘 :
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(UserSearchActivity.this.getCurrentFocus() .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);点击屏幕空白部分关闭软件盘:
@Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (getCurrentFocus() != null && getCurrentFocus().getWindowToken() != null) {((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(UserSearchActivity.this.getCurrentFocus() .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);} } return super.onTouchEvent(event);}