Android - 自动打开菜单项而不是显示下拉列表

Android - Open a menu item automatically instead of showing drop down list

我得到了一个只有一个菜单项的菜单。当我单击操作栏中的 3 点菜单图标时,将打开一个下拉列表以显示可供选择的单个项目。

如何在用户单击菜单图标时自动处理该菜单项,而不显示下拉列表(意味着应该为用户自动选择菜单项)?

您可以使用 onMenuOpened 覆盖行为:

onMenuOpened

added in API level 1 boolean onMenuOpened (int featureId, Menu menu) Called when a panel's menu is opened by the user. This may also be called when the menu is changing from one type to another (for example, from the icon menu to the expanded menu).