All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

Expandable Navigation Drawer Android

Last Updated : Mar 11, 2024

Expandable Navigation Drawer Android

In this article we will show you the solution of expandable navigation drawer android, swiping from the left side of the screen or pressing the programme icon just on action bar will bring up the navigation drawer.

A view called Android ExpandableListView displays items in a two-level list that scrolls vertically.

By allowing two layers, which are groupings that can be conveniently enlarged and collapsed via touching to see, it varies from a ListView.

The action bar is not covered by the expanding navigation drawer, which instead overlays the content.

Whenever the drawer is fully opened, the action bar modifies its content by deleting any actions that are specific to the view below the navigation drawer and changing its current action bars title to the app name.

The regular action items such Settings and Help are still available in the overflow menu.

Step By Step Guide On Expandable Navigation Drawer Android :-

navigationView = (NavigationView) findViewById(;
drawerLayout = (DrawerLayout) findViewById(;
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            public boolean onNavigationItemSelected(MenuItem item) {
                Intent intent;
                int id = item.getItemId();
                if (id == {
                    Intent favoritesIntent = new Intent(MainActivity.this, Favorites.class);
                } else if (id == {
                    Intent settingsIntent = new Intent(MainActivity.this, Settings.class);
                return true;
        ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.openDrawer, R.string.closeDrawer){
            public void onDrawerClosed(View drawerView) {
            public void onDrawerOpened(View drawerView) {
        ImageView titleLogo = (ImageView) findViewById(;
        titleLogo.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
            public boolean onCreateOptionsMenu(Menu menu) {
             getMenuInflater().inflate(, menu);
            return true;
  1. Create a new Android Studio project.
  2. Introducing a dependency into the project, The Design Patterns Navigation drawer will be used in this discussion. As a result, also include mentioned Material design dependency in the app-level Gradle file.
  3. Then the Setting Navigation View Item Selected Listener to handle the item click of the navigation menu
  4. After that we see This method will trigger on item Click of navigation menu
  5. Then Check to see which item was being clicked and perform appropriate action
  6. Then Initializing Drawer Layout and ActionBarToggle
  7. Then the Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank
  8. Inflate the menu; this adds items to the action bar if it is present.
  9. Making a menu in the menu file, Make a menu folder in the res folder.
  10. Invoke the javascript command in the activity_main.xml file to decide up the basic things necessary for the Route planning Drawer while continuing to work with the activity_main.xml file.
  11. Include the Open Close strings in string.xml, then run the code below in the app/res/values/strings.xml file.
  12. Working with the MainActivity File, run the code in the MainActivity file to display the menu button on the activity bar and implement the navigation drawer's open/close functionality.

Conclusion :-

To add an expandable list view to the navigation drawer, please advise.

Although I set the drawer layout in activity_main.xml, I cannot move past MainActivity.

Given that my menu contains a large number of items, I wanted to create a NavigationDrawer with an ExpandableListView within.

I therefore produced this test project. Also animated is the ExpandableListView.

I hope this article on expandable navigation drawer android helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Dikshita

Passionate Electronics and Communication Engineering student with expertise in web development (HTML, CSS, JS,PHP, Bootstrap, React.js) and content writing. Eager problem solver and tech enthusiast, adept at creating engaging web experiences.

Follow Dikshita On Linkedin 🡪