0

I've seen it being asked before in Actionbar not shown with AppCompat but I tried the solution and it didn't work for me. The menu items do not show up in the action bar, in my phone that has a menu button there is nothing in the actionbar except the up button and if I click on the phone menu all the items show up in the popup menu. In my tablet that does not have a menu button there is a more option in the action bar (the 3 vertical squares) where the menu items are (even though there is a lot of room). I am using the support package. my menu file is

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:compat="http://schemas.android.com/apk/res-auto">

<item
    android:id="@+id/menu_search"
    android:showAsAction="always"
    android:icon="@android:drawable/ic_menu_search"
    android:title="@string/menu_search"/>

<item
    android:id="@+id/menu_play"
    android:showAsAction="always"
    android:icon="@android:drawable/ic_media_play"
    android:title="@string/menu_play"/>    

</menu>

the style is Theme.AppCompat.Light and I add it

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.book, menu);
    return true;
}

and my activity extends android.support.v7.app.ActionBarActivity . Thank you

Community
  • 1
  • 1
yaronbic
  • 282
  • 1
  • 14

1 Answers1

0

Your method should be :

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.book,menu);
    return true;
}

It inflates the xml but doesn't know to which menu !

Leonardo
  • 3,141
  • 3
  • 31
  • 60
  • Sorry, my method is as you described I fixed it above. I just accidentally removed that part when I pasted it into the description here because I removed other irrelevant code and accidentally removed the menu too. – yaronbic Jul 30 '14 at 07:26