/**
* 隐藏输入软键盘
* @param context
* @param view
*/
public static void hideInputManager(Context context,View view){
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (view !=null && imm != null){
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏
//imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
//imm.hideSoftInputFromWindow(view.getWindowToken(), 0x0002);
}
}
public void hideInputMethod() {
try {
getWindow().getDecorView().findFocus().clearFocus(); //清理焦点
} catch (Exception e) {
}
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
System.out.println("开始了。。。。。。");
if (imm.isActive() && this.getCurrentFocus() != null) {
System.out.println("我进来了啊。。。。");
if (this.getCurrentFocus().getWindowToken() != null) {
System.out.println("执行了啊。。。。。");
imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
/*InputMethodManager imm = (InputMethodManager) a.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(a.getWindow().getDecorView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}*/
}
另在AndroidManifest.xml里面也添加过android:windowSoftInputMode="stateAlwaysHidden"
网上能用的方法都试过,都是无效果,另外还换过手机,重启一个新项目也没有效果