Android IT: android
Android應用開發中有時可能會須要經過代碼控制輸入法軟件盤的顯示與隱藏,以下: ide
方法一: post
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEdit.getWindowToken(), 0); //myEdit是你的EditText對象 spa下面就能夠經過下面方法能夠恢復顯示 對象
boolean showSoftInput(View view, int flags, ResultReceiver resultReceiver)
boolean showSoftInput(View view, int flags)
void showSoftInputFromInputMethod(IBinder token, int flags) token
方法二: 開發
protected void hideKeyboard() {
InputMethodManager localInputMethodManager = (InputMethodManager) getSystemService("input_method");
View currentFocus = getCurrentFocus();
if (currentFocus != null) {
IBinder localIBinder = getCurrentFocus().getWindowToken();
localInputMethodManager.hideSoftInputFromWindow(localIBinder, 0);
}
} get