If the focus is set, the pop-up form is the current operation window. If you want the following activity response button, you need to register the keyboard event on the popupwindow, then, call the activity component to respond to the corresponding event. However, popupwindow seems to have only one ondismiss listener. How can I register a keyboard event listener?
You can use setonkeylistener to listen to a view in popupwindow and capture Keyboard Events. There is a view in popupwindow. You can use this view to add a keyboard event and set setonkeylistener to the view on the outermost layer.
For example
Menuview. setbackgrounddrawable (New bitmapdrawable ());
Menuview. setfocusable (true );
Menuview. setfocusableintouchmode (true );
Menuview. setonkeylistener (New onkeylistener ()
{
@ Override
Public Boolean onkey (view V, int keycode, keyevent event)
{
// Todo auto-generated method stub
If (event. getaction () = keyevent. keycode_menu)
{
Log. V ("keycode", "/" + keycode );
Popupback. Dismiss ();
Popupwindow. Dismiss ();
Return false;
}
Return false;
}
});
Refer to this example to add the above method to implement the function of clicking the menu key to close the menu.
Http://blog.csdn.net/kkfdsa132/article/details/6403404