简体   繁体   English

检测按下后退按钮时是否显示选项菜单

[英]Detect if options menu is displayed when back button is pressed

My back button is overridden for ... reasons. 由于...原因,我的后退按钮被覆盖。 I've implemented a new feature, the options menu, and I need unique function calls if the back button is pressed while this options menu is up versus when it is not up. 我实现了一项新功能,即选项菜单,如果在此选项菜单处于打开状态时(而不是未处于打开状态)按下了后退按钮,则需要唯一的函数调用。 How can I discern if the menu is up when the back button is pressed? 按下后退按钮时如何辨别菜单是否打开? Thanks guys! 多谢你们!

Use a boolean . 使用boolean Set it to true in onPrepareOptionsMenu() . onPrepareOptionsMenu()其设置为true Set it to false in onOptionsMenuClosed() . onOptionsMenuClosed()中将其设置为false

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

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