Reputation: 1
How do I get the hamburger icon back for the navigation drawer? the AppBarConfiguration
changes it into a back arrow, why is that?
This is my code below:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = this;
init_v3();
BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(R.id.home, R.id.nav_tasks)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);
}
Upvotes: 0
Views: 115
Reputation: 40830
You should add all the fragments that you don't want the up/back button to show up in the appBarConfiguration
In your example, this up/back button won't show up in R.id.nav_tasks
& R.id.home
fragments as you already added them. >> if you have more fragments, then add them into the below separating between them with comma.
And to show up the Drawer burger icon, you need to call setOpenableLayout(drawerLayout)
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.home,
R.id.nav_tasks)
.setOpenableLayout(drawerLayout)
.build();
Upvotes: 1