Search code examples
androidkotlinnavigation

What is the NavigationUI class for?


I am starting to use NavController and I have seen that NavigationUI can make things easier, I have read the documentation, but it is not very clear to me.

https://developer.android.com/reference/androidx/navigation/ui/NavigationUI

If someone could explain to me its main uses or what it is useful for, thank you


Solution

  • NavigationUI is a static.

    It includes some auxiliary functions.

    onNavDestinationSelected

    Attempt to navigate to the [NavDestination] associated with the given MenuItem

    navigateUp

    Handles the Up button by delegating its behavior to the given NavController.

    setupActionBarWithNavController

    Sets up the ActionBar

    setupWithNavController

    Sets up a [Toolbar] for use with a [NavController]

    ...

    In short, it will connect to NavController. There are methods to make navigation processes easier.

    Source