My Android App has one SherlockFragmentActivity which contains a ViewPager with three SherlockListFragments. Know i want to display different ActionItems in the ActionBar. For example one SettingsItem on all three Fragments and on each Fragment a unique ActionItem for example different sort types. Now i use this code in my Fragment:
@Override
public void onCreateOptionsMenu( Menu menu, MenuInflater inflater )
{
super.onCreateOptionsMenu( menu, inflater );
inflater.inflate( R.menu.sort_menu, menu );
}
And this code in my Activity:
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
menu.add( Menu.NONE, PREFERENCES_ID, Menu.NONE, getString( R.string.menu_preferences ) )
.setIcon( R.drawable.ic_menu_settings_dark )
.setShowAsAction( MenuItem.SHOW_AS_ACTION_ALWAYS );
return super.onCreateOptionsMenu( menu );
}
The problem is that if i start my app no ActionItems appeare on the first tab. If i slide to another tab and then back again the ActionItems appeare. Sometimes i see only one ActionItem for example the settings item which is created by the parent Activity. Knows anybody a good solution to show some ActionItems on each tab and some unique ActionItems for each tab. I didn't want to copy code to each tab.
EDIT The position of the tab is not important. On the first app start i see no ActionItems on the actual tab.