NavOptions.Builder



Builder for constructing new instances of NavOptions.

Summary

Public constructors

android

Public functions

NavOptions
android
NavOptions.Builder

Sets a custom Animation or Animator resource for the enter animation.

android
NavOptions.Builder

Sets a custom Animation or Animator resource for the exit animation.

android
NavOptions.Builder

Launch a navigation target as single-top if you are making a lateral navigation between instances of the same target (e.g. detail pages about similar data items) that should not preserve history.

android
NavOptions.Builder

Sets a custom Animation or Animator resource for the enter animation when popping off the back stack.

android
NavOptions.Builder

Sets a custom Animation or Animator resource for the exit animation when popping off the back stack.

android
inline NavOptions.Builder
<T : Any> setPopUpTo(inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

android
NavOptions.Builder
setPopUpTo(destinationId: @IdRes Int, inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

android
NavOptions.Builder
<T : Any> setPopUpTo(route: KClass<T>, inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

android
NavOptions.Builder
<T : Any> setPopUpTo(route: T, inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

android
NavOptions.Builder
setPopUpTo(route: String?, inclusive: Boolean, saveState: Boolean)

Pop up to a given destination before navigating.

android
NavOptions.Builder
setRestoreState(restoreState: Boolean)

Whether this navigation action should restore any state previously saved by setPopUpTo or the popUpToSaveState attribute.

android

Public constructors

Builder

Builder()

Public functions

build

fun build(): NavOptions
Returns
NavOptions

a constructed NavOptions

setEnterAnim

fun setEnterAnim(enterAnim: @AnimRes @AnimatorRes Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the enter animation.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
enterAnim: @AnimRes @AnimatorRes Int

Custom animation to run

Returns
NavOptions.Builder

this Builder

See also
enterAnim

setExitAnim

fun setExitAnim(exitAnim: @AnimRes @AnimatorRes Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the exit animation.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
exitAnim: @AnimRes @AnimatorRes Int

Custom animation to run

Returns
NavOptions.Builder

this Builder

See also
exitAnim

setLaunchSingleTop

fun setLaunchSingleTop(singleTop: Boolean): NavOptions.Builder

Launch a navigation target as single-top if you are making a lateral navigation between instances of the same target (e.g. detail pages about similar data items) that should not preserve history.

Parameters
singleTop: Boolean

true to launch as single-top

setPopEnterAnim

fun setPopEnterAnim(popEnterAnim: @AnimRes @AnimatorRes Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the enter animation when popping off the back stack.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
popEnterAnim: @AnimRes @AnimatorRes Int

Custom animation to run

Returns
NavOptions.Builder

this Builder

See also
popEnterAnim

setPopExitAnim

fun setPopExitAnim(popExitAnim: @AnimRes @AnimatorRes Int): NavOptions.Builder

Sets a custom Animation or Animator resource for the exit animation when popping off the back stack.

Note: Animator resources are not supported for navigating to a new Activity

Parameters
popExitAnim: @AnimRes @AnimatorRes Int

Custom animation to run

Returns
NavOptions.Builder

this Builder

See also
popExitAnim

setPopUpTo

inline fun <T : Any> setPopUpTo(inclusive: Boolean, saveState: Boolean = false): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
<T : Any>

route from a KClass for destination to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

true if the back stack and the state of all destinations between the current destination and T should be saved for later restoration via setRestoreState or the restoreState attribute using the same route from KClass as popUpToRouteClass (note: this matching route is true whether inclusive is true or false).

Returns
NavOptions.Builder

this Builder

setPopUpTo

fun setPopUpTo(
    destinationId: @IdRes Int,
    inclusive: Boolean,
    saveState: Boolean = false
): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
destinationId: @IdRes Int

The destination to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

true if the back stack and the state of all destinations between the current destination and destinationId should be saved for later restoration via setRestoreState or the restoreState attribute using the same ID as popUpToId (note: this matching ID is true whether inclusive is true or false).

Returns
NavOptions.Builder

this Builder

setPopUpTo

fun <T : Any> setPopUpTo(
    route: KClass<T>,
    inclusive: Boolean,
    saveState: Boolean = false
): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
route: KClass<T>

from the KClass of the destination T to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

true if the back stack and the state of all destinations between the current destination and T should be saved for later restoration via setRestoreState or the restoreState attribute using the same route from KClass as popUpToRouteClass (note: this matching route is true whether inclusive is true or false).

Returns
NavOptions.Builder

this Builder

setPopUpTo

fun <T : Any> setPopUpTo(route: T, inclusive: Boolean, saveState: Boolean = false): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
route: T

route from an Object for destination to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

true if the back stack and the state of all destinations between the current destination and route should be saved for later restoration via setRestoreState or the restoreState attribute using the same route from an Object as popUpToRouteObject (note: this matching route is true whether inclusive is true or false).

Returns
NavOptions.Builder

this Builder

setPopUpTo

fun setPopUpTo(route: String?, inclusive: Boolean, saveState: Boolean = false): NavOptions.Builder

Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.

Parameters
route: String?

route for destination to pop up to, clearing all intervening destinations.

inclusive: Boolean

true to also pop the given destination from the back stack.

saveState: Boolean = false

true if the back stack and the state of all destinations between the current destination and route should be saved for later restoration via setRestoreState or the restoreState attribute using the same ID as popUpToRoute (note: this matching ID is true whether inclusive is true or false).

Returns
NavOptions.Builder

this Builder

setRestoreState

fun setRestoreState(restoreState: Boolean): NavOptions.Builder

Whether this navigation action should restore any state previously saved by setPopUpTo or the popUpToSaveState attribute. If no state was previously saved with the destination ID being navigated to, this has no effect.