2012-01-09 63 views

回答

0

試試這個。

InputMethodManager inputManager = (InputMethodManager) (YourActivity) 
          .getSystemService(Context.INPUT_METHOD_SERVICE); 
        inputManager.hideSoftInputFromWindow(home.getCurrentFocus() 
          .getWindowToken(), 
          InputMethodManager.HIDE_NOT_ALWAYS); 
1

Close/hide the Android Soft Keyboard

您可以強制的Android使用 InputMethodManager,呼籲hideSoftInputFromWindow,在 傳遞一個包含您的編輯字段窗口令牌隱藏虛擬鍵盤。

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0); 

這將強制鍵盤在所有情況下被隱藏。在某些 的情況下,您希望通過InputMethodManager.HIDE_IMPLICIT_ONLY 作爲第二個參數,以確保您只在用戶沒有明確強制顯示(通過按住菜單)時隱藏鍵盤。

相關問題