[android-developers] ActionBarSherlock - Overflow menu does not appear at first launch on 2.x devices when using setHasOptionsMenu true on fragments
The menu items in the action bar are not displayed after each fresh start of the application. I have a ViewPager holding about 5 fragments, all having hasSetOptionsMenu(true) as they are adding one or more menu items beside the one from the activity. I am using ActionBarSherlock library, with ForcedOverflow theme to have an overflow menu on all devices (irrespective to OS version).
- reproducible only on 2.x devices (3.x and 4.x are fine);
- onCreateOptionsMenu from FragmentActivity is called multiple times as the menu is invalidated after each Fragment that has hasSetOptionsMenu(true) is loaded into the ViewPager;
- setting hasSetOptionsMenu(false) to all visible fragments solves the issue;
- issue seems to be solved with one more menu invalidation: rotating device causes the overflow menu to appear;
- in completion to above note: the overflow menu is triggered to appear on scrolling to another fragment only if that one has another menu item beside the ones from the overflow menu;
- I have found an Android bug (here) that is describing an issue when ActionBar menu items do not appear sometimes due to a race condition triggered by calling setCurrentPage for the same item but neither of the two workarounds from comment #8 did helped me (this seems to be a plausible cause as during debugging, sometimes when holding the app for a longer times to investigate, the overflow menu was displayed in the end);
- this could also be a ABS bug, as found two issues that might be related to this problem: this and this.
Have you encountered this before?
-- You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home