隐藏软键盘(解决自定义Dialog中无法隐藏的问题)

   /**
* Dialog中隐藏软键盘不管用
* @param activity
*/
public static void HideSoftKeyBoard(Activity activity){
try{
InputMethodManager imm =((InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE));
if(imm.isActive()){
imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
}
}
catch(Exception ex){
LogUtil.WriteError(ex,tag+"->HideSoftKeyBoard()");
}
} /**
* Dialog中隐藏软键盘
* @param activity
*/
public static void HideSoftKeyBoardDialog(Activity activity){
try{
InputMethodManager imm = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_NOT_ALWAYS, 0);
}
catch(Exception ex){
LogUtil.WriteError(ex,tag+"->HideSoftKeyBoard()");
}
}
上一篇:ucGUI的学习小结


下一篇:从零开始学 Web 之 CSS3(八)CSS3三个案例