Reputation: 3926
I am using Action Bar Sherlock. I have a problem with the arrangement of the icons in action bar.
From the image below the icons should be interchanged I tried all the way but couldnt find the solution.
Here is my code
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.add(1, 1, 1, "CREATE").setIcon(R.drawable.img_yo_create)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
SubMenu submenus = menu.addSubMenu("SORT");
submenus.add(2, 2, 2, "CARDS ADDED BY ME");
submenus.add(2, 3, 3, "CARDS FROM MERCHANT");
submenus.add(2, 4, 4, "ALL CARDS");
submenus.add(2, 5, 5, "HELP .?");
MenuItem subitem = submenus.getItem();
subitem.setIcon(R.drawable.img_sorting);
subitem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return;
}
Upvotes: 1
Views: 1861
Reputation: 8225
You have not set an order to your Submenu when you call:
SubMenu submenus = menu.addSubMenu("SORT");
Take a look through docs for menu. Then take some time to look into the getOrder()
Since they have set constants you should use for your order, not just 1 as you did with your CREATE MenuItem you should really read that first.
You should call: addSubMenu(int, int, int, CharSequence)
Example (I have not tried this):
SubMenu submenus = menu.addSubMenu(2,2,2,"SORT");
Upvotes: 2