输入法隐藏、弹出
2015-08-22 12:11
309 查看
推荐这种 简单方便:
剩下的几种方法 按需使用:
一、打开输入法窗口:
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
// 接受软键盘输入的编辑文本或其它视图
imm.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);
二、关闭出入法窗口
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(OpeListActivity.this.getCurrentFocus().getWindowToken()
,InputMethodManager.HIDE_NOT_ALWAYS);
//接受软键盘输入的编辑文本或其它视图
inputMethodManager.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);
三、如果输入法打开则关闭,如果没打开则打开
InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
四、获取输入法打开的状态
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
boolean isOpen=imm.isActive();
isOpen若返回true,则表示输入法打开
//如果输入法打开则关闭,如果没打开则打开 void shutDownInput(){ InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); }
剩下的几种方法 按需使用:
一、打开输入法窗口:
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
// 接受软键盘输入的编辑文本或其它视图
imm.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);
二、关闭出入法窗口
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(OpeListActivity.this.getCurrentFocus().getWindowToken()
,InputMethodManager.HIDE_NOT_ALWAYS);
//接受软键盘输入的编辑文本或其它视图
inputMethodManager.showSoftInput(submitBt,InputMethodManager.SHOW_FORCED);
三、如果输入法打开则关闭,如果没打开则打开
InputMethodManager m=(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
四、获取输入法打开的状态
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
boolean isOpen=imm.isActive();
isOpen若返回true,则表示输入法打开
相关文章推荐
- jqgrid控件列分组
- 绘制圆角的 LinearLayout
- Java通过new Date() 得到的时间与系统时间差N个小时的解决办法
- Myeclipse快捷键以及Myeclipse优化总结
- 第1讲Spark纯实战公益大讲坛:通过案例实战掌握高可用HA下的Spark集群部署
- 动态规划 01背包 最大子数组和 最小路径 斐波那契数列
- 【LeetCode】205. Isomorphic Strings
- hdu__KMP算法模板题【持续更新中】
- Could not launch "xxx". process launch failed: timed out waiting for app to launch解决方案
- 数字三角形——动态转移方程
- [LeetCode]Single Number
- UICollectionview Xib 行间距
- V3版本微信支付
- 用户态 内核态
- ListView UI 混乱问题
- C++ 编程个人总结
- MySQLCluster安装配置(三)
- MySQLCluster安装配置(四)
- 数据库扫盲一(主键、外键)
- MySQLCluster安装配置(二)