ActionBarSherlock
ActionBarSherlock copied to clipboard
Action item on menu doesn't show api < 8
Hi,
I have a tab which contains fragment on it. I need to have differents actions in every tabs.
If i want to add action item, i override this function on fragment :
public void onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu, MenuInflater inflater)
But it doesn't show anything for api < 8 and work well for api > 8 (working with nexus 4).
Is this issue known or someone already had this bug ?
Did you have setHasOptionsMenu(true) on any Fragment.OnActivityCreated methods?
yes of course without it wont works on api > 8 so i have it.
i followed the tabs pager exemple...
''' public class AgendaFragment extends SherlockFragment{ @Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub // Permet d'activer le menu (lance le onCreateOptionMenu) setHasOptionsMenu(true); super.onActivityCreated(savedInstanceState); }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()){
case R.id.action_add:
// todo
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu,
MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
menu.clear();
inflater.inflate(R.menu.menu_main_agenda_list, menu);
}
} ''' i tried it in the public void onCreate(Bundle savedInstanceState) method but doesn't work too.