Adding Items To Navigation Drawer
To add items to navigation drawer, you need to edit two files. MainActivity.java and activity_main_drawer.xml
Adding Category to menu
Go to activity_main_drawer.xml and find the code mentioned below
<group>
<item
android:id="@+id/nav_home"
android:icon="@drawable/ic_home"
android:title="Home" />
<item
android:id="@+id/nav_categories"
android:icon="@drawable/ic_categories"
android:title="Categories" />
<item
android:id="@+id/nav_offline"
android:icon="@drawable/ic_file_download"
android:title="Saved Posts"/>
</group>and paste the below code inside the <group> ... </group>
<item
android:id="@+id/nav_my_category_id"
android:icon="@drawable/ic_add"
android:title="My Category Name"/>Now the first part is completed. Lets proceed to the second step.
Go to MainActivity.java file and find the code mentioned below
You need to add following file to the onNavigationItemSelected just before the editor.apply();
Full Code Example
Adding Social Media Links
Last updated