Search code examples
androidandroid-actionbar

Action bar does not show


I tried to implement an action bar in my application.

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/itemAdd"
        android:showAsAction="ifRoom|withText"
        android:title="ADD">
    </item>
    <item
        android:id="@+id/itemRefresh"
        android:showAsAction="ifRoom|withText"
        android:title="REFRESH">
    </item>
    <item
        android:id="@+id/itemHelp"
        android:title="HELP">
    </item>

</menu>

And created menu

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }

enter image description here

But it does not show the action bar even if minSdkVersion is 11. What is the reason?


Solution

  • Remove your theme for your actionbar activity in androidManifest file. Now it will work...

    <application
        android:allowBackup="true"
        android:icon="@drawable/tasktodo"
        android:label="@string/app_name"
        >
    

    Don't add any theme in your application manifest file. If you added one, please remove and try running it...