I\'ve created a small app that has three fragments for top-level navigation through a BottomNavigationView. If you launch the app and click on a navigation button on the bottom
In Java this works for me:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
navController = Navigation.findNavController(this, R.id.nav_host_fragment);
AppBarConfiguration appBarConfiguration = new AppBarConfiguration
.Builder(navController.getGraph())
.build();
NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration);
navController.addOnDestinationChangedListener((controller, destination, arguments) -> {
toolbar.setTitle(destination.getLabel());
toolbar.setNavigationIcon(null);
});