Using the Fragment classes and their layouts
This stage has three steps. First, we need to edit the menu of the navigation drawer 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.kt
to switch between the different Fragment
instances when the user taps on the menu of the navigation drawer.
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" android:title="Insert" /> <item android:id="@+id/nav_delete" android:icon="@drawable/ic_menu_gallery...