JakeWharton/ActionBarSherlock — Issue #94: Fragment.onPrepareOptionsMenu not called until menu button pressed
Author: petedoyle
Created: 2011-10-27 04:49:21+00:00
State: open

In 3.3.1 Fragment#onCreateOptionsMenu(...) is called when a fragment is displayed, but Fragment#onPrepareOptionsMenu(android.view.Menu) is only called after pressing the Menu button. This is on a 2.3 device.

I have a fragment that effectively has Play/Pause/Stop actions, and I use onPrepareOptionsMenu() to disable them depending on the current state. Without calling onPrepareOptionsMenu(), all three show until I press the menu key.

Just for reference (in case its helpful), the stock ACL dispatches onPrepareOptionsMenu() from FragmentActivity#onPreparePanel(int featureId, View view, Menu menu).