安卓软键盘的显示与隐藏
2017-06-29 10:32
162 查看
1: 软键盘的显示
当前布局必须已经完成加载,如果还未绘制完成,则showSoftInput()方法不起作用。如果要再布局文件加载后就显示软键盘,可以通过postDelayed的方式来延迟执行showSoftInput()。延迟时间不能太短,一般要在50ms以上。
2:软键盘的隐藏
当前布局必须已经完成加载,如果还未绘制完成,则showSoftInput()方法不起作用。如果要再布局文件加载后就显示软键盘,可以通过postDelayed的方式来延迟执行showSoftInput()。延迟时间不能太短,一般要在50ms以上。
// 显示软键盘 new Handler().postDelayed(new Runnable() { @Override public void run() { imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { etSMS.requestFocus(); imm.showSoftInput(view, 0); } } }, 100);
2:软键盘的隐藏
public void hideSoftInputWindow() { InputMethodManager imm = (InputMethodManager) getSystemService(Context .INPUT_METHOD_SERVICE); if (this.getCurrentFocus() != null) { if (this.getCurrentFocus().getWindowToken() != null) {// 点击空白位置 隐藏软键盘 imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }
相关文章推荐
- 安卓学习之控制软键盘的显示和隐藏
- Android监听软键盘的显示与隐藏
- Android软键盘自动显示,手动控制显示与隐藏
- Android软键盘的隐藏显示研究 推荐
- Android 软键盘的显示与隐藏(isActive一直为true的情况)
- Android软键盘的显示与隐藏
- Android,隐藏/显示软键盘
- Android软键盘的隐藏显示研究
- 安卓开发中的双日期选择控件(可隐藏日,只显示年月)
- android 软键盘的显示和隐藏方法
- Android软键盘的显示与隐藏
- 安卓如何实现单击一下软键盘就隐藏
- 解析android中隐藏与显示软键盘及不自动弹出键盘的实现方法
- Android软键盘的隐藏显示研究
- EditText获取和失去焦点,软键盘的关闭,和软键盘的显示和隐藏的监听
- wince软键盘的隐藏和显示
- 安卓键盘显示隐藏和光标显示隐藏
- android隐藏以及显示软键盘以及不自动弹出键盘的方法
- 安卓开发中的双日期选择控件(可隐藏日,只显示年月)
- 安卓开发中的双日期选择控件(可隐藏日,只显示年月)