My activity extends ActionBarActivity
As is covered in the documentation, if you are using the appcompat_v7
backport of the action bar, and its associated ActionBarActivity
, your menu resource needs to have showAsAction
in a namespace custom to your app:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/delete"
yourapp:showAsAction="ifRoom|withText"
android:icon="@drawable/ic_delete_image"
android:title="delete"/>
</menu>
Here is a complete sample project demonstrating the use of the appcompat_v7
action bar.