Actionbar not shown with AppCompat

electrofant picture electrofant · Aug 29, 2013 · Viewed 21.7k times · Source

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?

Answer

flx picture flx · Aug 29, 2013

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>