NavAction
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 | |
---|---|
Creates a new NavAction for the given destination. |
|
<init>(@IdRes : Int, @Nullable : NavOptions?) Creates a new NavAction for the given destination. |
|
<init>(@IdRes : Int, @Nullable : NavOptions?, @Nullable : Bundle?) Creates a new NavAction for the given destination. |
Public methods | |
---|---|
Bundle? |
Gets the argument bundle to be used by default when navigating to this action. |
Int |
Gets the ID of the destination that should be navigated to when this action is used |
NavOptions? |
Gets the NavOptions to be used by default when navigating to this action. |
Unit |
setDefaultArguments(@Nullable : Bundle?) Sets the argument bundle to be used by default when navigating to this action. |
Unit |
setNavOptions(@Nullable : NavOptions?) Sets the NavOptions to be used by default when navigating to this action. |
Public constructors
<init>
NavAction(@IdRes : 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(
@IdRes : Int,
@Nullable : 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 |
NavOptions?: special options for this action that should be used by default |
<init>
NavAction(
@IdRes : Int,
@Nullable : NavOptions?,
@Nullable : Bundle?)
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 |
NavOptions?: special options for this action that should be used by default |
defaultArgs |
Bundle?: argument bundle to be used by default |
Public methods
getDefaultArguments
@Nullable fun getDefaultArguments(): Bundle?
Gets the argument bundle to be used by default when navigating to this action.
Return | |
---|---|
Bundle? |
bundle of default argument values |
getDestinationId
fun getDestinationId(): Int
Gets the ID of the destination that should be navigated to when this action is used
getNavOptions
@Nullable fun getNavOptions(): NavOptions?
Gets the NavOptions to be used by default when navigating to this action.
setDefaultArguments
fun setDefaultArguments(@Nullable : Bundle?): Unit
Sets the argument bundle to be used by default when navigating to this action.
Parameters | |
---|---|
defaultArgs |
Bundle?: argument bundle that should be used by default |
setNavOptions
fun setNavOptions(@Nullable : 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 |