In a word game for Android I currently have a hardcoded menu inflated from left_drawer_menu.xml and consisting of 3 groups (my turn, opponent turn and finally other
menu.add(R.id.my_move, i, i, "Item " + i);
You are also assigning the order (3rd param) as i. I am guessing that this is overriding the groupId. Try setting it as NONE as mentioned here
menu.add(R.id.my_move, i, NONE, "Item " + i);
Edit: Maybe something like this
MenuItem lastItem = menu.findItem(R.id.);
int lastOrder= lastItem.getOrder();
menu.add(R.id.my_move, i, lastOrder-5, "Item " + i);
Order is a combination of category and order, so it might not be as straight forward as this.