PopupWindow中EditText被touc时弹出键盘异常解决办法
2012-05-29 12:11
134 查看
今天继续做浮框效果,发现当PopupWindow当中包含EditText时,popupWindow出现后,editText自动猎取焦点,但是软键盘却不能跟着出现。
同样的问题: http://stackoverflow.com/questions/3915230/how-to-show-keyboard-on-popupwindow
http://stackoverflow.com/questions/4593610/android-popupwindow-window-focus-selection/8500786#8500786
原因终于找到了,在我的代码中:
PopupWindow mPopupWindow = new PopupWindow(poupView, 300,300); 我用的是两个参数的构造函数。
查看PopupWindow.java的源代码后发现:
/**
* <p>Create a new non focusable popup window which can display the
* <tt>contentView</tt>. The dimension of the window must be passed to
* this constructor.</p>
*
* <p>The popup does not provide any background. This should be handled
* by the content view.</p>
*
* @param contentView the popup's content
* @param width the popup's width
* @param height the popup's height
*/
public PopupWindow(View contentView, int width, int height) {
this(contentView, width, height, false);
}
/**
* <p>Create a new popup window which can display the <tt>contentView</tt>.
* The dimension of the window must be passed to this constructor.</p>
*
* <p>The popup does not provide any background. This should be handled
* by the content view.</p>
*
* @param contentView the popup's content
* @param width the popup's width
* @param height the popup's height
* @param focusable true if the popup can be focused, false otherwise
*/
public PopupWindow(View contentView, int width, int height, boolean focusable) {
if (contentView != null) {
mContext = contentView.getContext();
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
setContentView(contentView);
setWidth(width);
setHeight(height);
setFocusable(focusable);
}
所以就明白,为什么软键盘会不出现了?
解决方法,换一个构造函数,哈哈。
同样的问题: http://stackoverflow.com/questions/3915230/how-to-show-keyboard-on-popupwindow
http://stackoverflow.com/questions/4593610/android-popupwindow-window-focus-selection/8500786#8500786
原因终于找到了,在我的代码中:
PopupWindow mPopupWindow = new PopupWindow(poupView, 300,300); 我用的是两个参数的构造函数。
查看PopupWindow.java的源代码后发现:
/**
* <p>Create a new non focusable popup window which can display the
* <tt>contentView</tt>. The dimension of the window must be passed to
* this constructor.</p>
*
* <p>The popup does not provide any background. This should be handled
* by the content view.</p>
*
* @param contentView the popup's content
* @param width the popup's width
* @param height the popup's height
*/
public PopupWindow(View contentView, int width, int height) {
this(contentView, width, height, false);
}
/**
* <p>Create a new popup window which can display the <tt>contentView</tt>.
* The dimension of the window must be passed to this constructor.</p>
*
* <p>The popup does not provide any background. This should be handled
* by the content view.</p>
*
* @param contentView the popup's content
* @param width the popup's width
* @param height the popup's height
* @param focusable true if the popup can be focused, false otherwise
*/
public PopupWindow(View contentView, int width, int height, boolean focusable) {
if (contentView != null) {
mContext = contentView.getContext();
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
setContentView(contentView);
setWidth(width);
setHeight(height);
setFocusable(focusable);
}
所以就明白,为什么软键盘会不出现了?
解决方法,换一个构造函数,哈哈。
相关文章推荐
- PopupWindow中EditText被touc时弹出键盘异常解决办法
- 手机浏览器浏览WebApp弹出的键盘遮盖住文本框的解决办法
- 解决办法:ios模拟器键盘不弹出
- 关于IE7打开任何网页弹出[未处理的异常('对象不支持此属性或方法')发生在iexplorer.exe]错误调试框的解决办法
- 软键盘弹出,listview上移并滚动到最后一条的解决办法
- ionic3开发系列——Android 端软键盘弹出后界面被压缩的解决办法
- 手机浏览器浏览WebApp弹出的键盘遮盖住文本框的解决办法
- Android-----解决EditText控件的自动弹出键盘的办法
- 微信内置浏览器浏览H5页面弹出的键盘遮盖文本框的解决办法(转)
- iOS 键盘收起异常的解决办法
- Android 软键盘弹出时,把整个界面往上挤 的解决办法
- Android软键盘弹出时挤压屏幕高度解决办法
- 创建手机页面弹出键盘的时候背景图片被挤上去的解决办法
- DataTable表添加新行时,弹出--ID列不能为""-- 异常的解决办法
- vs2015刚打开时弹出遇到异常的解决办法
- 安卓EditText有时点击后无法自动弹出键盘的解决办法;TextWatcher多次调用问题
- Visual Studio2012打开时弹出“遇到异常:这可能是由某个扩展导致的”错误的解决办法
- Alterdialog中不弹出软键盘原因分析及解决办法
- [Cordova/Phonegap] Cordova iOS 应用在第三方输入法的键盘弹出(点击输入框)时,页面不上移,导致输入框被键盘遮挡 的解决办法
- -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.【创建键盘监听事件,然后操作键盘(弹出、收回),结果在运行程序时出现如下错误(如有知道解决办法的朋友请留言探讨!)】