简体   繁体   中英

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!!

So I cannot remove the setFocusable(true); flag
but I want to receive the keyEvents inside the popup anyway.

So how can I receive key events on an focusable popupwindow?

我建议您使用自定义的布局,该布局已覆盖调度键事件,然后将事件发送到popupWindow。我所看到的是,确定键事件已被确实提供给popupwindow中的视图组。请检查ViewRootImpl deliveryKeyEvent和PopUpWindow的dispatchKeyEvent。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM