1.Android 輸入軟鍵盤(pán)打開(kāi)的方法
View view = getCurrentFocus();if (view != null) {? ? ? ? ? ? InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);}
2.Android輸入軟鍵盤(pán)關(guān)閉的方法:
View view = getCurrentFocus();if(view !=null) {? ? ? ? ? ? ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(),0);? ? ? ? }
有時(shí)候卵惦,在關(guān)閉軟件盤(pán)時(shí)出現(xiàn) 無(wú)效 的情況。
修改Activity的windowSoftInputMode 為 :stateAlwaysHidden
android:windowSoftInputMode="stateAlwaysHidden"