Android點擊空白區域隱藏鍵盤
/** * 點擊空白區域隱藏鍵盤. * @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); }</pre>
本文由用戶 juio 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!