标签:
/** * 点击空白区域隐藏键盘. * @param event the event * @return true, if successful */ @Override public boolean onTouchEvent(MotionEvent event) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (event.getAction() == MotionEvent.ACTION_DOWN) { if (EBDocuSearchActivity.this.getCurrentFocus() != null) { if (EBDocuSearchActivity.this.getCurrentFocus().getWindowToken() != null) { imm.hideSoftInputFromWindow(EBDocuSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } } return super.onTouchEvent(event); }
/**隐藏键盘 */ protected void hideInputKeyboard(View v) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); } /**弹起键盘 */ protected void showInputKeyboard(View v) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(v, 0); }
标签:
原文地址:http://my.oschina.net/u/141132/blog/416705