android / architecture-components-samples

Samples for Android Architecture Components.
https://d.android.com/arch
Apache License 2.0
23.45k stars 8.28k forks source link

NavigationUI.onNavDestinationSelected(MenuItem) #844

Open squm opened 4 years ago

squm commented 4 years ago

Hello, I noticed using NavigationUI.onNavDestinationSelected turns the Back button into Home button, keeps the Back button icon

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
    return NavigationUI.onNavDestinationSelected(item, navController)
            || super.onOptionsItemSelected(item);
}