I am trying to control which elements of the action bar are displayed if there is limited space, and have tried the solution in this question and answer: Priority icon in the action bar
Everything works fine, except that I want to keep the order of the icons in a way that differs from the priority, while the solution above makes the elements reorder. Is there a way to set the priority for displaying items without changing the display order of items in the action bar?
I tried to change the order of elements in xml, and this does not affect the order of elements as displayed (without orderInCategory, changing the order in the file leads to a change in the order of elements as shown).
I am developing against ICS.
menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/action_edit" android:icon="@android:drawable/ic_menu_edit" android:title="@string/action_edit" android:showAsAction="ifRoom" android:orderInCategory="1" /> <item android:id="@+id/action_undo" android:icon="@android:drawable/ic_menu_revert" android:title="@string/action_undo" android:showAsAction="ifRoom" android:orderInCategory="2" /> <item android:id="@+id/action_delete" android:icon="@android:drawable/ic_menu_delete" android:title="@string/action_delete" android:showAsAction="ifRoom" android:orderInCategory="3" /> <item android:id="@+id/action_addnew" android:icon="@android:drawable/ic_menu_add" android:title="@string/action_addnew" android:showAsAction="ifRoom" android:orderInCategory="0" /> </menu>
Thanks.
source share