NavAction

open class NavAction
kotlin.Any
   ↳ androidx.navigation.NavAction

Navigation actions provide a level of indirection between your navigation code and the underlying destinations. This allows you to define common actions that change their destination or NavOptions based on the current NavDestination.

The NavOptions associated with a NavAction are used by default when navigating to this action via NavController#navigate(int) or NavController#navigate(int, Bundle).

Actions should be added via NavDestination#putAction(int, int) or NavDestination#putAction(int, NavAction).

Summary

Public constructors
<init>(destinationId: Int)

Creates a new NavAction for the given destination.

<init>(destinationId: Int, navOptions: NavOptions?)

Creates a new NavAction for the given destination.

Public methods
open NavOptions?

Gets the NavOptions to be used by default when navigating to this action.

open Unit
setNavOptions(navOptions: NavOptions?)

Sets the NavOptions to be used by default when navigating to this action.

open Int

Gets the ID of the destination that should be navigated to when this action is used

Public constructors

<init>

NavAction(destinationId: Int)

Creates a new NavAction for the given destination.

Parameters
destinationId Int: the ID of the destination that should be navigated to when this action is used.

<init>

NavAction(destinationId: Int, navOptions: NavOptions?)

Creates a new NavAction for the given destination.

Parameters
destinationId Int: the ID of the destination that should be navigated to when this action is used.
navOptions Int: special options for this action that should be used by default

Public methods

getNavOptions

open fun getNavOptions(): NavOptions?

Gets the NavOptions to be used by default when navigating to this action.

setNavOptions

open fun setNavOptions(navOptions: NavOptions?): Unit

Sets the NavOptions to be used by default when navigating to this action.

Parameters
navOptions NavOptions?: special options for this action that should be used by default

getDestinationId

open fun getDestinationId(): Int

Gets the ID of the destination that should be navigated to when this action is used