I created a navigation menu XML file for my project. nav_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group
android:id="@+id/group_note"
android:checkableBehavior="single">
<item
android:id="@+id/note"
android:icon="@drawable/all_notes"
android:iconTint="@color/black1"
android:title="Notes"/>
</group>
<group
android:id="@+id/group_days"
android:checkableBehavior="single">
<!-- all days will come here -->
</group>
<group
android:id="@+id/group_setting"
android:checkableBehavior="none">
<item
android:id="@+id/setting"
android:icon="@drawable/setting"
android:iconTint="@color/black1"
android:title="Settings" >
</item>
</group>
group_days item will dynamically. But the problem is, I except group_days after group_note. But it comes after group_setting! I don't know why.
答案 0 :(得分:0)
我认为问题是您在items
中添加的所有XML
都有默认顺序,这意味着下一个添加的items
将会在您的方案中添加已添加的项目。尝试为您的商品订购,例如Notes
它显然为0:android:orderInCategory="0"
和Settings
尝试:android:orderInCategory="2"
然后为每个新添加的商品集类别到1
。例如:
menu.add(R.id.monday, Menu.NONE, 1, "Monday");
menu.add(R.id.tuesday, Menu.NONE, 1, "Tuesday");
//and so on