Navigation Drawer Android Studio With Nested Fragment

Navigation drawer Android Studio example guide you to create a nested fragment.

Navigation drawer Android example will give you a professional structure to create an Android app with child fragment and sliding menu.

This Navigation drawer Android example is the second part of basic navigation drawer in Android tutorial.

Complete all the steps from that example then follow steps of this tutorial.

Visit this link for more information about navigation drawer.

First, see the output of navigation drawer android studio example, then we will make it.

Download Source Code For Navigation Drawer Android tutorial

[sociallocker] Download DrawerFragmentDemonuts [/sociallocker]


Creating Navigation Drawer Android Tutorial step by step

Step 1: Follow all the steps from basic navigation drawer in Android tutorial.

After you have completed above tutorial, you will have one android project with navigation drawer.

Now follow below steps.

Step 2: Creating FriendActivity

Make a new activity named “FriendActivity.”

Copy below code into the

Add following code into activity_friend.xml

Step 3: Adding FriendNested Fragment

Create a new fragment and give the name as “FriendNestedFragment.”

Add below code in fragment_friend_nested.xml

Copy below source code in

Step 4: Updating FriendListFragment

Update fragment_friend_list.xml as per below


Description of addFragment() method

This method will open a new fragment in the container box.

This method will put the fragment in the backstack before opening it. That means when the user clicks on the back button this fragment will be open if new any nested fragment or activity is opened.

Here, we have opened a FriendActivity, so when you come back from the FriendActivity, FriendNestedFragment will be opened as shown in the output video.

Step 5: Creating NotiSecondNestedFragment

Prepare a new fragment named NotiSecondNestedFragment.

Copy below source code in fragment_noti_second_nested.xml

Add following in

Step 6: Creating NotiNestedFragment

Make a new fragment named NotiNestedFragment.

Paste below source code in fragment_noti_nested.xml

Put following in

Step 7: Updating NotificationFragment

Update fragment_notification.xml as per below

Update as following code

Now run your project, and it should work like shown in the output video.

If you have any query, then drop it in the comment box. I will be happy to help you. Thank you 🙂

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

2 Responses

  1. Nilmar Castro says:

    Hi Hardik

    Did you forgot to put a container_body file ?

    • Hardik Parsania says:

      container_body is not separate file.
      it is an id for FrameLayout present in the activity_main.xml file.
      activity_main.xml is present in the basic nav drawer example, not in this tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *