View view = getCurrentFocus();if (view != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);}
View view = getCurrentFocus();if(view !=null) { ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(),0); }
有时候,在关闭软件盘时出现 无效 的情况。
修改Activity的windowSoftInputMode 为 :stateAlwaysHidden
android:windowSoftInputMode="stateAlwaysHidden"