FragmentActivity.onPrepareOptionsMenu()

765 views
Skip to first unread message

drsoran

unread,
Jul 7, 2011, 2:18:52 PM7/7/11
to jakewharton-projects
Hi!

What is the reason why
android.support.v4.app.FragmentActivity.onPrepareOptionsMenu(android.support.v4.view.Menu)
does nothing and does not calls the implementation of the runtime
type? The original method
android.support.v4.app.FragmentActivity.onPrepareOptionsMenu(android..view.Menu)
is final and surely not meant to be overwritten.

I have a Menu that contains a MenuItem with a SubMenu attached. The
entries of the SubMenu are checkable and exclusive. After creating the
SubMenu in onCreateOptionsMenu(), I have no chance to set the initial
value. During creation, I call setChecked( true ) on the right
MenuItem of the SubMenu but after opening the menu the last added
MenuItem is always checked.

According to the Android docs, one should set the initial value in the
onPrepareOptionsMenu(). But this is never called.

Any ideas on this?

Thanks, drsoran

Jake Wharton

unread,
Jul 7, 2011, 3:33:00 PM7/7/11
to jakewharto...@googlegroups.com
The onPrepareOptionsMenu(android.support.v4.view.Menu) will be called whenever onCreateOptionsMenu() returns true. However, the disconnect you are seeing is due to the custom item view representation that I wrote to handle mapping the support MenuItem to an action item view or a native MenuItem. This behavior can be seen in the 'styled' sample for the action bar background and navigation submenus.

The fix for this will be tied to the other issue you submitted. I should be starting it tonight. I have more already implemented that I remembered so i'm certain this will make it into 3.1.

drsoran

unread,
Jul 8, 2011, 12:11:09 AM7/8/11
to jakewharton-projects
Good to hear that. Should I create a new issue in your issue tracker
for this? I was unsure if this was is really an issue so I used your
group in first place.

Jake Wharton

unread,
Jul 8, 2011, 10:56:47 AM7/8/11
to jakewharto...@googlegroups.com
You don't need to create a new issue. When #33 is fixed just know that this will be too.
Reply all
Reply to author
Forward
0 new messages