My application is using Actionbarsherlockc ViewpagerIndicator. Each page uses 1 fragment. I want each page to have a different action menu, so how can I archive this?
I tried to use onCreateOptionsMenufor each SherlockFragment, but the menu of the action bar did not appear, I also tried to find some methods for adding the menu programmatically, but in no way.
@Override
public void onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu, com.actionbarsherlock.view.MenuInflater inflater)
{
inflater.inflate(R.menu.main, menu);
super.onCreateOptionsMenu(menu, inflater);
}
Thanks you!
* EDIT: add more details *
If I use onCreateOptionsMenu in Activity, the menu (action item) is usually displayed.
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater menuInflater = getSupportMenuInflater();
menuInflater.inflate(R.menu.main, menu);
This is how I set the ActionBar in the ViewPager
final ActionBar actionbar = getSupportActionBar();
actionbar .setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionbar .setDisplayHomeAsUpEnabled(true);
actionbar .setTitle("olala");
mFragmentAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mFragmentAdapter);
mIndicator.setViewPager(mPager);
mIndicator.setOnPageChangeListener(new MyPageChangeListener());
mPager.setCurrentItem(3);