Using the Fragment classes and their layouts
This stage has three steps. First, we need to edit the menu of the Navigation Drawer layout to reflect the options the user has. Next, we need a View
instance in the layout to hold whatever the active Fragment
instance is, and finally, we need to add code to MainActivity.java
to switch between the different Fragment
instances when the user taps on the menu.
Editing the Navigation Drawer menu
Open the activity_main_drawer.xml
file in the res/menu
folder of the project explorer. Edit the code within the group
tags that we saw earlier to reflect our menu options of Insert, Delete, Search, and Results:
<group android:checkableBehavior="single"> <item android:id="@+id/nav_insert" android:icon="@drawable/ic_menu_camera" ...