InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // 获得InputMethodManager的实例 if (imm.isActive()) { imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); // 关闭软键盘,开启方法相同,这个方法是切换开启与关闭状态的 }强制关闭键盘
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(EvaluateActiivty.this.getCurrentFocus().getWindowToken(), 0);
View view = getWindow().peekDecorView(); if (view != null) { InputMethodManager inputmanger = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0); }
版权声明:本文为博主原创文章,未经博主容许不得转载。java