Binoy Babu
Binoy Babu

Reputation: 17119

ActionBar is not working

I am trying to enable ActionBar in an Activity.

Here is my Manifest file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.assistant.lab.royale"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="15"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".LabAssistant"
            android:label="@string/app_name" 
            android:theme="@android:style/Theme.Holo">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

and here's the code :

.....
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.abmenu, menu);
    return true;
}
.....

I'm following the guide over here. The ActionBar menu should show up now according to the guide but all I'm getting is the old options menu. Why?

Edit : menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/menuReset"
        android:alphabeticShortcut="s"
        android:icon="@android:drawable/ic_menu_preferences"
        android:showAsAction="withText"
        android:title="@string/menu_reset"/>
    <item
        android:id="@+id/menuAbout"
        android:alphabeticShortcut="b"
        android:icon="@android:drawable/ic_menu_info_details"
        android:showAsAction="withText"
        android:title="@string/menu_about"/>
</menu>

Upvotes: 1

Views: 1407

Answers (1)

adneal
adneal

Reputation: 30804

Did you include showAsAction in your abmenu.xml items?

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_save"
      android:icon="@drawable/ic_menu_save"
      android:title="@string/menu_save"
      // This line //
      android:showAsAction="ifRoom|withText" />
</menu>

Upvotes: 1

Related Questions