解决Dialog 消失,输入法不消失的问题
2015-08-18 19:25
393 查看
前言:今天遇到一个奇怪的问题,Activity 里面弹出一个 dialog , 这个dialog里面有EditText 。
问题:当 dialog 里面的输入法出现的时候,此时让diolog 消失,输入法不消失。
效果图如下:
dialog 创建方法:
1、使用下面的代码没有效果
2、解决方法
问题:当 dialog 里面的输入法出现的时候,此时让diolog 消失,输入法不消失。
效果图如下:
dialog 创建方法:
final AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog dialog = builder.create() ;
1、使用下面的代码没有效果
/** * 隐藏软键盘 */ void hideInput () { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if(inputMethodManager.isActive()){ inputMethodManager.hideSoftInputFromWindow( this.getCurrentFocus().getWindowToken(), 0); } }
2、解决方法
//隐藏输入法 InputMethodManager manager= (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); manager.hideSoftInputFromWindow( dialog.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
相关文章推荐
- Activity生命周期
- IOS-TextField控件详解
- 将输入的字符串(字符串仅包含小写字母‘a’到‘z’),按照如下规则,循环转换后输出:a->b,b->c,…,y->z,z->a;若输入的字符串连续出现两个字母相同时,后一个字母需要连续转换2次。例如:
- 自定义异常类一
- fanqiang
- python视频教程大全集下载啦!超级全的教程!
- Dream------spark--spark集群的环境搭建
- Fragment 实现tab页卡切换并保存界面状态,动态添加Fragment
- jQuery 从input中读取的内容的类型
- 【ODPS】本地数据库数据批量上传到ODPS中
- java请求https
- 使用tinyxml解析XML配置文件
- hdu4109(拓扑排序,dp)
- android客户端从服务器端获取json数据并解析的实现代码(重要)
- 给phpcms v9加入一个主题radio无线电button,它可反复使用,以创建不同的专题部分内容编辑器,添加一个主题来定义自己的领域
- leetcode---different ways to add parentheses
- [Unity]SQLite-C#调用
- TCP快速重传与快速恢复原理分析
- HUD-5399 Too Simple(数学)
- HDU 1865 六度分离 <裸的迪杰斯特拉算法>