在程序中加入以下代碼時,軟鍵盤會出現:
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
如果要讓軟鍵盤消失,則爲以下代碼:
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);