Question

I've started using the ActionBar coming with the AppCompat library. But any action I add to this, shows up in the overflow menu. I'm pretty sure I've skipped something, but I don't know at all. Here's my menu file:

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

    <item
        android:id="@+id/connect_plus"
        android:icon="@drawable/ic_google_plus"
        android:title="Connect to Google+"
        android:showAsAction="always"
        android:titleCondensed="Connect to Google+">
    </item>

</menu>

And any configuration in the onCreate method from an activity extending from ActionBarActivity:

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);

Did I miss something?

Was it helpful?

Solution

Did I miss something?

Yes.

You need to use your own namespace:

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

    <item
        android:id="@+id/connect_plus"
        android:icon="@drawable/ic_google_plus"
        android:title="Connect to Google+"
        yourapp:showAsAction="always"
        android:titleCondensed="Connect to Google+">
    </item>

</menu>

as is shown in the documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top