繁体   English   中英

通过单击按钮打开选项菜单

[英]Open the Options Menu by clicking on the button

单击按钮如何打开选项菜单? 以下代码不起作用:

openOptionsMenu();

谢谢

我的问题解决了。 我使用Options Menu而不是Popup Menu

我发现的唯一方法是模拟KeyEvent。 这使选项菜单出现

    BaseInputConnection  mInputConnection = new BaseInputConnection( findViewById(R.id.main_content), true);
KeyEvent kd = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU);
KeyEvent ku = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MENU);
mInputConnection.sendKeyEvent(kd);
mInputConnection.sendKeyEvent(ku);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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