Skip to content Skip to sidebar Skip to footer

Actionbar Action Items Not Showing

i have a very simple code, but a problem that I cannot solve even after long google searching. I want to have some Action Items in my ActionBar, but whenever I run the App, all I s

Solution 1:

This is because if you use the support AppCompat ActionBar library and ActionBarActivity you should create your menus in a different than the standard way of creating XML menus in ActioBarSherlock or the default ActionBar.

So try this code:

<menuxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"><itemandroid:id="@+id/action_search"android:icon="@drawable/ic_action_search"android:title="@string/action_search"app:showAsAction="always"  /><itemandroid:id="@+id/action_compose"android:icon="@drawable/ic_action_compose"android:title="@string/action_compose"app:showAsAction="always"/></menu>

and report if this works.

Note: check the extra prefix xmlns:app which should be used instead!

Solution 2:

May sure that you are not using a Style that is rendering your Action Items invisible.

For example if you are using "android:Theme.Holo.Light.DarkActionBar" you get a black action bar so you won't be able to see your black items.

Switch to "android:Theme.Holo.Light" and they will show up.

Look in the file (for example) res/values-v14/styles.xml

Solution 3:

Here you go, you need to add the menu in your xml like this:

<menuxmlns:android="http://schemas.android.com/apk/res/android" ><itemandroid:id="@+id/menu_settings"android:orderInCategory="0"android:showAsAction="always"android:icon="@drawable/menu"><menu><itemandroid:id="@+id/action_search"android:icon="@drawable/ic_action_search"android:title="@string/action_search"android:showAsAction="always"  /><itemandroid:id="@+id/action_compose"android:icon="@drawable/ic_action_compose"android:title="@string/action_compose"android:showAsAction="always"/></menu></item></menu>

Solution 4:

Try this:

@OverridepublicbooleanonCreateOptionsMenu(Menu menu) {
    // Inflate the menu items for use in the action barMenuInflaterinflater= getMenuInflater();
    inflater.inflate(R.menu.main_activity_actions, menu);
    returntrue;
}

Post a Comment for "Actionbar Action Items Not Showing"