private InputMethodManager inputMethodManager;
//inputMethodManager的实例化必须在oncreat之后;不然获取不到getSystemService;
inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
private boolean hideKeyboard(){
if(inputMethodManager.isActive(reciverName) ||inputMethodManager.isActive(reciverTel)||inputMethodManager.isActive(reciverAddr3)){
reciverAddr.requestFocus();//强制获取焦点,不然getCurrentFocus().getWindowToken()会报错
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
inputMethodManager.restartInput(reciverAddr3);
return true;
}
return false;
}
判断软键盘是否打开并关闭
最新推荐文章于 2024-08-25 03:43:08 发布