我有一个editText和两个按钮,当我点击取消,我有禁用编辑文本和隐藏键盘。键盘没有被解雇,即使我试图解雇Android
case R.id.verify_cancel:
hideMobileNoEditOption();
showAndHideError(verify_layout, false);
showAndHideError(mobile_error_tv, false);
mobile_number_et.clearFocus();
这是hideMobileNoEditOption()的代码;
mobile_number_et.clearFocus();
AppUtil.hideSoftKeyboard(this);
mobile_number_et.setCursorVisible(false);
mobile_number_et.setFocusable(false);
mobile_number_et.setEnabled(false);
mobile_number_et.setTextIsSelectable(false);
mobile_number_et.setTextColor(ContextCompat.getColor(getBaseContext(), R.color.zero_title));
这是隐藏键盘的代码。
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (null != activity.getCurrentFocus()) {
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
但是我的关键董事会没有因为上帝知道的原因而被解雇,任何人都可以请帮忙吗?在此先感谢
也许你应该问神,因为他知道 –
请大家帮忙找到解决方案。 –
你确定你的'hideSoftInputFromWindow'方法被执行了吗?如果在隐藏软键盘之前清除焦点'(null!= activity.getCurrentFocus())''条件返回false并且不会隐藏键盘。 –