隐藏软键盘方法:

getWindow().addFlags(

WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);


源码注释:

/** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with

         * respect to how this window interacts with the current method.  That

         * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the

         * window will behave as if it needs to interact with the input method

         * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is

         * not set and this flag is set, then the window will behave as if it

         * doesn't need to interact with the input method and can be placed

         * to use more space and cover the input method.

         */

public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;


该方法会导致界面里面所有需要弹出软键盘的控件均无法显示软键盘。


当然当我们需要清除该状态时,可以在输入控件的Touch事件里面进行解除

EditText.setOnTouchListener(new OnTouchListener() {

@Override

public boolean onTouch(View v, MotionEvent event) {

// TODO Auto-generated method stub

getWindow().clearFlags(

WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

return false;

}

});







更多相关文章

  1. 简洁、高效、可自定义的开源的Android评论控件---CommentView
  2. Android轮播图控件CustomBanner的使用讲解
  3. Android界面编程——Android高级UI组件(三)
  4. Android(安卓)事件分发
  5. android动态生成控件
  6. Android(安卓)TextView 实现跑马灯效果
  7. Android(安卓)在Service里面启动Activity
  8. [置顶] android软键盘的隐藏问题
  9. 管理android 键盘自动弹出 关闭

随机推荐

  1. Android使用高德和风天气Sdk获取定位实况
  2. Android(安卓)Q 适配
  3. 让Android程序获得系统权限,实现关机重启,
  4. 读oschina android 开源app代码 - 笔记。
  5. Android——SystemProperties的应用
  6. Android(安卓)4.0 SDK的离线方式安装
  7. AndroidGUI30:定制按钮
  8. android自定义访问权限permission
  9. [android] 解决DatePickerDialog和TimePi
  10. 手机自动化培训:Appium介绍