Bug 3560 - Implementation of InvalidateOptionsMenu() in an Activity
Summary: Implementation of InvalidateOptionsMenu() in an Activity
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-02-21 10:30 UTC by Cody Johnson
Modified: 2013-12-05 18:35 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Cody Johnson 2012-02-21 10:30:56 UTC
It appears that calling InvalidateOptionsMenu(), by the android documentation should result in calling the OnPrepareOptionsMenu() method, but it does not in Mono, it calls the OnCreateOptionsMenu() method instead.


 On Android 3.0 and higher, the options menu is considered to always be open when menu items are presented in the action bar. When an event occurs and you want to perform a menu update, you must call invalidateOptionsMenu() to request that the system call onPrepareOptionsMenu()
Comment 1 Cody Johnson 2012-02-22 08:46:00 UTC
Update: calling base.OnPrepareOptionsMenu() provides the expected behavior.
Comment 2 Atsushi Eno 2012-03-29 05:00:35 UTC
Could you please elaborate on the actual code example that shows our InvalidateOptionsMenu() is failing? I found this method used in our HoneycombGallery sample [*1] and verified it works like the original Java sample code. If I understand what you commented, toggling the titles does not result in OnPrepareOptionsMenu(), but it actually did. OnCreateOptionsMenu() is also invoked, but that does not contradict the documentation. It should be fine as long as OnPrepareOptionsMenu() is invoked. This behavior is also identical to the original Java sample.

[*1] https://github.com/xamarin/monodroid-samples/blob/master/HoneycombGallery/MainActivity.cs#L255
Comment 3 PJ 2013-11-19 17:05:21 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 4 PJ 2013-12-05 18:35:40 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.