Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

NavigationUI

class NavigationUI
kotlin.Any
   ↳ androidx.navigation.ui.NavigationUI

Class which hooks up elements typically in the 'chrome' of your application such as global navigation patterns like a navigation drawer or bottom nav bar with your NavController.

Summary

Public methods
static Boolean
navigateUp(@NonNull navController: NavController, @Nullable openableLayout: Openable?)

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

static Boolean
navigateUp(@NonNull navController: NavController, @NonNull configuration: AppBarConfiguration)

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

static Boolean
onNavDestinationSelected(@NonNull item: MenuItem, @NonNull navController: NavController)

Attempt to navigate to the NavDestination associated with the given MenuItem.

static Unit
setupActionBarWithNavController(@NonNull activity: AppCompatActivity, @NonNull navController: NavController)

Sets up the ActionBar returned by AppCompatActivity#getSupportActionBar() for use with a NavController.

static Unit
setupActionBarWithNavController(@NonNull activity: AppCompatActivity, @NonNull navController: NavController, @Nullable openableLayout: Openable?)

Sets up the ActionBar returned by AppCompatActivity#getSupportActionBar() for use with a NavController.

static Unit
setupActionBarWithNavController(@NonNull activity: AppCompatActivity, @NonNull navController: NavController, @NonNull configuration: AppBarConfiguration)

Sets up the ActionBar returned by AppCompatActivity#getSupportActionBar() for use with a NavController.

static Unit
setupWithNavController(@NonNull toolbar: Toolbar, @NonNull navController: NavController)

Sets up a Toolbar for use with a NavController.

static Unit
setupWithNavController(@NonNull toolbar: Toolbar, @NonNull navController: NavController, @Nullable openableLayout: Openable?)

Sets up a Toolbar for use with a NavController.

static Unit
setupWithNavController(@NonNull toolbar: Toolbar, @NonNull navController: NavController, @NonNull configuration: AppBarConfiguration)

Sets up a Toolbar for use with a NavController.

static Unit
setupWithNavController(@NonNull collapsingToolbarLayout: CollapsingToolbarLayout, @NonNull toolbar: Toolbar, @NonNull navController: NavController)

Sets up a CollapsingToolbarLayout and Toolbar for use with a NavController.

static Unit
setupWithNavController(@NonNull collapsingToolbarLayout: CollapsingToolbarLayout, @NonNull toolbar: Toolbar, @NonNull navController: NavController, @Nullable openableLayout: Openable?)

Sets up a CollapsingToolbarLayout and Toolbar for use with a NavController.

static Unit
setupWithNavController(@NonNull collapsingToolbarLayout: CollapsingToolbarLayout, @NonNull toolbar: Toolbar, @NonNull navController: NavController, @NonNull configuration: AppBarConfiguration)

Sets up a CollapsingToolbarLayout and Toolbar for use with a NavController.

static Unit
setupWithNavController(@NonNull navigationView: NavigationView, @NonNull navController: NavController)

Sets up a NavigationView for use with a NavController.

static Unit
setupWithNavController(@NonNull bottomNavigationView: BottomNavigationView, @NonNull navController: NavController)

Sets up a BottomNavigationView for use with a NavController.

Public methods

static fun navigateUp(
    @NonNull navController: NavController,
    @Nullable openableLayout: Openable?
): Boolean

Handles the Up button by delegating its behavior to the given NavController. This should generally be called from AppCompatActivity#onSupportNavigateUp().

If you do not have a Openable layout, you should call NavController#navigateUp() directly.

Parameters
navController NavController: The NavController that hosts your content.
openableLayout Openable?: The Openable layout that should be opened if you are on the topmost level of the app.
Return
Boolean True if the NavController was able to navigate up.
static fun navigateUp(
    @NonNull navController: NavController,
    @NonNull configuration: AppBarConfiguration
): Boolean

Handles the Up button by delegating its behavior to the given NavController. This is an alternative to using NavController#navigateUp() directly when the given AppBarConfiguration needs to be considered when determining what should happen when the Up button is pressed.

In cases where no Up action is available, the AppBarConfiguration#getFallbackOnNavigateUpListener() will be called to provide additional control.

Parameters
navController NavController: The NavController that hosts your content.
configuration AppBarConfiguration: Additional configuration options for determining what should happen when the Up button is pressed.
Return
Boolean True if the NavController was able to navigate up.

onNavDestinationSelected

static fun onNavDestinationSelected(
    @NonNull item: MenuItem,
    @NonNull navController: NavController
): Boolean

Attempt to navigate to the NavDestination associated with the given MenuItem. This MenuItem should have been added via one of the helper methods in this class.

Importantly, it assumes the menu item id matches a valid action id or destination id to be navigated to.

By default, the back stack will be popped back to the navigation graph's start destination. Menu items that have android:menuCategory="secondary" will not pop the back stack.

Parameters
item MenuItem: The selected MenuItem.
navController NavController: The NavController that hosts the destination.
Return
Boolean True if the NavController was able to navigate to the destination associated with the given MenuItem.

setupActionBarWithNavController

static fun setupActionBarWithNavController(
    @NonNull activity: AppCompatActivity,
    @NonNull navController: NavController
): Unit

Sets up the ActionBar returned by