-
Notifications
You must be signed in to change notification settings - Fork 27
OnPrepareOptionsMenu() doesn't get called #33
Comments
The reason I want to get this work is I need to change the menu items at runtime. I use a different approach though. But it's not perfect. |
I think because |
Actually I suspect the reason is because we use If I use |
I am also using OnPrepareOptionsMenu to control menu visibility according to some data context... do you have some other way to know when the user is touching the Menu button ? |
No, I can't find a way to do this. I used a different approach to get the same behavior. In my app, there is a "select all" function in the menu items to select all the items in the list view and "deselect all" to reverse, so I need to dynamically switch between two. What I did is when the activity first launches, it only shows "select all". Then when all items are selected or "select all" is clicked, "select all" will be removed and "deselect all" will be add into menu items. It is the only way I can think of. |
So something I do is actually have "CreateLegacyBar" method in my code and based on the context it will put in different menu items. For instance if I have a list of items with check boxes I have 3 different menus Whenever the items checked changes on the list I actually go ahead and re-create my LegacyBar. I did the initial implementation of the overflow so i am up for new ideas. Currently you must use some sort of LegacyBarActivity base class which will do cleanup oncreateoptionsmenu and onprepareoptionsmenu. |
If the device doesn't have physical menu button,
OnPrepareOptionsMenu
won't get called when I click on the overflow menu button.But in the official Google ActionBar implementation, it gets called.
I looked at ActionBarSherlock, it seems to be a problem as well.
I tried let
OnCreateOptionsMenu
returntrue
to getOnPrepareOptionsMenu
called but no luck. See here.The text was updated successfully, but these errors were encountered: