Android – How to add item to the top ActionBar

androidandroid-actionbar

I would like to add new icon to the top action bar, bet instead of adding to the top, the icon appear on the bottom of the screen. How can I add item to the top ActionBar?

XML:

<menu xmlns:android="http://schemas.android.com/apk/res/android">    
    <item android:id="@+id/preferences"
        android:icon="@drawable/preferences"    
        android:title="Preferences"
        android:showAsAction="always|withText"/>

    <item android:id="@+id/help"
        android:title="Help"
        android:icon="@drawable/ic_action_search" />    
</menu>

Java:

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

Best Answer

Taken from http://developer.android.com/guide/topics/ui/actionbar.html#SplitBar

To enable split action bar, simply add uiOptions="splitActionBarWhenNarrow" to your or manifest element.

So if you want to have an item in the top. Make sure that this line is NOT in your code.