I am working with the Android 3.0.
I have in the action bar 3 items and one of them is the menu of the application, it also has sub-menu in it.
I want to change the order of the icons so the menu won't be in the right place, I want it to be between the two other items. I tried to change the order in the xml with no success. Does anyone has an idea how to set the order?
Try setting android:menuCategory
and android:orderInCategory
for your menu items to set the ordering.
Example:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/launch_search"
android:icon="@android:drawable/ic_menu_search"
android:title="@string/search_programs"
android:menuCategory="container"
android:orderInCategory="2"
android:showAsAction="always" />
<item android:id="@+id/preferences_screen"
android:icon="@android:drawable/ic_menu_preferences"
android:title="@string/preferences" />
<item android:id="@+id/refresh"
android:icon="@drawable/ic_menu_refresh"
android:menuCategory="container"
android:orderInCategory="1"
android:title="@string/refresh_items"
android:showAsAction="ifRoom" />
</menu>
It will have the same effect as declaring launch_search -action as last, but this way you'll have your actions in the right order for 2.x and older devices while being able to control action ordering for 3.x -devices.
The menu will always go to the right, you cannot control its placement.
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