/**
* alex
* 隐藏软键盘
*/
public static void hiddenSoftKey(Activity activity) {
((InputMethodManager) MyApplication.getInstance().getSystemService(
Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(activity
.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
之前工具类封装的方法,
今天在dialog时候,edt要隐藏时调用该方法报null 。
getwindowtoken 取得的是null。
解决办法: 不用activity,直接用edt来gettoken即可。
/**
* alex
* 隐藏软键盘
*/
public static void hiddenSoftKey(EditText edt) {
((InputMethodManager) MyApplication.getInstance().getSystemService(
Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(edt.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
替换掉上面的方法即可。