Search code examples
androidandroid-actionbarandroid-actionbar-compatandroid-appcompat

Actionbar not shown with AppCompat


I am backporting my app to API7 with AppCompat and have a problem with the actionbar.

When I use FragmentActivity the actionbar is shown on my phone (API18), but with ActionBarActivity it shows up as the optionmenu by pressing the menubutton.

On the emulator with API7 the actionbar is always shown as an optionsmenu.

Any ideas?


Solution

  • Use the compat name space for your menu items like this:

    <menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:compat="http://schemas.android.com/apk/res-auto" >
        <item android:id="@+id/action_whatever"
          android:icon="@drawable/ic_action_whatever"
          android:title="@string/whatever"
          compat:showAsAction="ifRoom"  />
    </menu>