Icons in actionbar do not appear

Asked

Viewed 99 times

-1

I have a Fragment and I’m putting these two methods in the class

 @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
    menuInflater.inflate(R.menu.alerta, menu);
    super.onCreateOptionsMenu(menu, menuInflater);
  }

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_item_new_quote:
            // TODO put your code here to respond to the button tap
            Toast.makeText(getActivity(), "ADD!", Toast.LENGTH_SHORT).show();
            return true;
        default:
            return true;
    }
}

and I have an xml file I created in the menu folder

But the icons don’t want to appear in actionbar at all...

2 answers

0


Solved my problem by putting on onCreate():

 setHasOptionsMenu(true);

-1

Try to get this super:

super.onCreateOptionsMenu(menu, menuInflater);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.