[英]android get keyEvent for focusable PopupWindow
I've got a popup-window like this: 我有一个这样的弹出窗口:
View view = li.inflate(R.layout.someview, null);
PopupWindow popup = new PopupWindow(context);
popup.setBackgroundDrawable(new BitmapDrawable());
popup.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popup.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
popup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
popup.setTouchable(true);
popup.setFocusable(true);
popup.setContentView(view);
Inside the popup-window there is an edittext which definitely needs to be able to get the focus!! 在弹出窗口中有一个edittext,它肯定需要能够获得焦点!
So I cannot remove the setFocusable(true);
所以我不能删除
setFocusable(true);
flag 旗
but I want to receive the keyEvents inside the popup anyway. 但是我还是想在弹出窗口中接收keyEvents。
So how can I receive key events on an focusable popupwindow? 那么,如何在可聚焦的弹出窗口上接收关键事件呢?
我建议您使用自定义的布局,该布局已覆盖调度键事件,然后将事件发送到popupWindow。我所看到的是,确定键事件已被确实提供给popupwindow中的视图组。请检查ViewRootImpl deliveryKeyEvent和PopUpWindow的dispatchKeyEvent。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.