I am trying to implement Android sidebar. I know how to implement sliding sidebar with Drawer layout. The first pic is list and when I click on one of the item it shows the relevant list items. How to do this? please help me.
Asked
Active
Viewed 1,497 times
2
-
2I would use fragments inside your DrawerLayout. When the user clicks on an item in the list, you can change the fragment which is displayed. – Code-Apprentice Jan 04 '17 at 06:11
-
1Use ExpandableListView and ExpandableListAdapter in place of list. – SHIVANI GARG Jan 04 '17 at 06:17
-
1@SHIVANIGARG That would work for the second "screen" assuming the "+" is a cue that the list expands when clicked. – Code-Apprentice Jan 04 '17 at 06:31
2 Answers
1
You can clear Whole Menu on Item Selection of NavigationView
mainNavigationMenu_.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
//IT WILL HAPPEN ON BASIS OF ITEM ID OF MENU....
navView.getMenu().clear();
navView.inflateMenu(R.menu.second_menu);
return true;
}
});
OR
you can change group of menu Simple and effective way.
Thanks :)

Community
- 1
- 1

Pratik Butani
- 60,504
- 58
- 273
- 437
0
I have followed the @Code-Apprentice comment.
Created a fragment for mainlist and another fragment for sublist. Once the mainlist item is selected, the mainlist fragment will be replaced by sublist with relevant data and added some fragment transaction animations. it worked well.

Voora Tarun
- 1,266
- 1
- 20
- 38