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;
}
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.
Check if you have android:uiOptions="splitActionBarWhenNarrow" in the activity definition in your AndroidManifest.xml. That's what makes action bar split to the bottom.
Check ActionBarSherlock for what you are doing. It will provide ActionBar functionality on the older android versions and will use native ActionBar when it's supported. It has sample application showcasing most of its settings http://actionbarsherlock.com/index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With