android add expand/collapse in navigation drawer menu

1.5k Views Asked by At

enter image description here

Hey guys this is my navigation drawer menu items.

    NavigationView nav  = (NavigationView) findViewById(R.id.nav_view);
    final DrawerLayout drawerlayout = (DrawerLayout) 
    findViewById(R.id.drawer_layout);
    Menu menu = navigationView.getMenu();
    SubMenu sub = menu.addSubMenu("Menu 1");
    sub.add("Menu 1.1");
    sub.add("Menu 1.2");
    sub.add("Menu 1.3");
    drawerlaayout.closeDrawers();

This how i create menu items.now i Want to add Expand/collapse option in each menu items.Menu 1,Menu 2,Menu 3.

1

There are 1 best solutions below

0
On BEST ANSWER

you could try these by doing r&d 1.try whether we can insert our custom layout for menu. if so, change the visibility of submenu. 2.direct drawable insert of icon into the menu.

if nothing helps try, 1.try with expandable recyclerview big nerd's library. obviously this will work. 2.click in the menu header.