Android 调出键盘和隐藏键盘
来源:互联网 发布:阿里云推荐码怎么用 编辑:程序博客网 时间:2024/05/21 10:54
Android 调出键盘和隐藏键盘
调出键盘
mEditText.requestFocus();InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);imm.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
隐藏键盘
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
关于 dialog
当使用的 dialog 中包含有 EditText 的时候,你在 show()
之后直接调用上面的代码是无法实现调出键盘的,解决方式非常简单,show()
之后 post 一帧即可。
mEditText.post(new Runnalbe() { @Override public void run() { mEditText.requestFocus(); InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT); }}
当然你不一定要这样 post,你也可以自己定义一个
Handler
来进行 post。
0 0
- Android 调出键盘和隐藏键盘
- android显示和隐藏键盘
- Android显示和隐藏键盘
- android 隐藏键盘 显示键盘
- 隐藏键盘和显示键盘
- android 键盘状态,获取键盘显示和隐藏
- android EditText出现后,自动调出键盘
- Android监听键盘的显示和隐藏
- Android 输入法键盘的隐藏和显示
- Android监听键盘显示和隐藏
- android 监听键盘的弹起和隐藏
- Android中如何显示和隐藏键盘
- Android 键盘的显示和隐藏
- Android监听键盘显示和隐藏
- Android edittext键盘的隐藏和显示
- android 中显示和隐藏键盘
- android 隐藏键盘
- 隐藏android键盘
- PHP学习笔记1-常量,函数
- SAE-上传本地图片到SAE的Storage(php版)
- 换今日特价图片---轻开电子商务系统(企业入门级B2C网站)
- 使用 JAX-RS 简化 REST 应用开发
- Connecting the dots with jQuery, JSONP, and WebAPI
- Android 调出键盘和隐藏键盘
- Matrix ,RectF
- BZOJ1004
- 将登太行雪满山
- Android高级界面组件的学习(三)
- 解决django TemplateDoesNotExist错误
- poj3411
- 2015062602 - 后悔
- java基础入门