Solve it! added "getSherlock().dispatchInvalidateOptionsMenu();" in 
onResume() for the FragmentActivity to force the menu invalidation. This 
seems to have solved the issue. I know this is a hack but did not managed 
to find another solution. Tried adding the menu invalidation to the 
fragments (onCreateView or onActivityCreated) as I got a suggestion to do 
that, but this did not fixed it. Thanks Kostya! 

On Tuesday, October 2, 2012 12:14:19 PM UTC+3, Kostya Vasilyev wrote:
>
> I've not encountered this exact bug, but recently spent a couple of days 
> trying to get an initially hidden button to show in the action bar (native, 
> on devices running 4.*, Galaxy S3 and Moto Razr).
>
> The item won't show as an icon or in the overflow despite me calling 
> setVisible(true) on the menu item (and doing "clever" things like calling 
> setVisible() multiple times, on neighbouring items, would really mess up 
> the action bar on my Galaxy Nexus).
>
> This one appears to be fixed in the latest AOSP source (reported by a user 
> with custom firmware), so the fix might make it into ActionBarSherlock. For 
> the native implementation, you could try calling invalidateOptionMenu on 
> the activity, maybe posted via a Handler. Or try adding an item to the menu 
> and immediately remove it.
>
> Again, not sure if it's the same bug, but it sounds close enough.
>
> -- K
>
> 2012/10/2 Miha m\ <[email protected] <javascript:>>
>
>> 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).
>>
>> What I have discovered after debugging and investigation:
>>  
>>    - 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<http://code.google.com/p/android/issues/detail?id=29472>) 
>>    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<https://github.com/JakeWharton/ActionBarSherlock/issues/187>and 
>>    this <https://github.com/JakeWharton/ActionBarSherlock/issues/570>.
>>
>> 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 
>> [email protected]<javascript:>
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to