This is the definition code for my complete drawer:
NavigationView navigationView = findViewById(R.id.nav_view);
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_lontr, R.id.nav_att, R.id.nav_djong,
R.id.nav_fon).setOpenableLayout(drawer)
.build();
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
NavController navController = navHostFragment.getNavController();
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration); // Here my nav action bar
NavigationUI.setupWithNavController(navigationView, navController);
Imagine that a user is in nav_lontr and I want to put a shortcut for him to go back to nav_home, it looks like this:
shortcuttoOther.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().getSupportFragmentManager().popBackStack();
}
});
After sending the popBackStack, the current fragment is closed, however, the appbar keeps the fragment's name closed, despite returning to the home nav, in addition, in the side drawer the fragment that was closed is also selected. Why even after closing the current fragment with popBackStack, my NavigationUI does not update my appBar with the title of the current label (home)?
Instead of displaying the title in the appbar of my fragment home, it displays the title of the fragment closed by the popbackstack, which is the fragment which has already been closed.