ActionBarSherlock icon indicating copy to clipboard operation
ActionBarSherlock copied to clipboard

Action item on menu doesn't show api < 8

Open NameX44 opened this issue 12 years ago • 2 comments

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 ?

NameX44 avatar Mar 11 '13 10:03 NameX44

Did you have setHasOptionsMenu(true) on any Fragment.OnActivityCreated methods?

iNoles avatar Mar 11 '13 23:03 iNoles

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.

NameX44 avatar Mar 12 '13 08:03 NameX44