I know how to make multiple top-level destinations for a navigation graph. Following the answers here is fine.
However I want to add, based on app user's desire (e.g. a button click), another top-level destination.
In compliance with the documentation :
//Redoing the navigation setup
int[] itemsId = new int[ menu.size() ];
for( int i = 0; i < menu.size(); i++ ) {
itemsId[i] = menu.getItem(i).getItemId();
}
mAppBarConfiguration = new AppBarConfiguration.Builder( itemsId )
.setDrawerLayout(drawer)
.build();
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
This piece of code was already in onCreate() of MainActivity.java file. Then after I add an menuItem I'm running the code again.
After navigating, the newly added menuItem still shows the back button on the top left, instead of the hamburger stack button.
Is what I want even possible ? Any ideas ?
P.S : I'm using the basic project template "Navigation Drawer Activity" of Android (when you want to start a new project).