NavOptions.Builder
public final class NavOptions.Builder
Builder for constructing new instances of NavOptions.
Summary
Public constructors |
|---|
Builder() |
Public methods |
|
|---|---|
final @NonNull NavOptions |
build() |
final @NonNull NavOptions.Builder |
setEnterAnim(@AnimRes @AnimatorRes int enterAnim)Sets a custom Animation or Animator resource for the enter animation. |
final @NonNull NavOptions.Builder |
setExitAnim(@AnimRes @AnimatorRes int exitAnim)Sets a custom Animation or Animator resource for the exit animation. |
final @NonNull NavOptions.Builder |
setLaunchSingleTop(boolean singleTop)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. |
final @NonNull NavOptions.Builder |
setPopEnterAnim(@AnimRes @AnimatorRes int popEnterAnim)Sets a custom Animation or Animator resource for the enter animation when popping off the back stack. |
final @NonNull NavOptions.Builder |
setPopExitAnim(@AnimRes @AnimatorRes int popExitAnim)Sets a custom Animation or Animator resource for the exit animation when popping off the back stack. |
final @NonNull NavOptions.Builder |
<T extends Object> setPopUpTo(boolean inclusive, boolean saveState)Pop up to a given destination before navigating. |
final @NonNull NavOptions.Builder |
setPopUpTo(@IdRes int destinationId, boolean inclusive, boolean saveState)Pop up to a given destination before navigating. |
final @NonNull NavOptions.Builder |
<T extends Object> setPopUpTo(Pop up to a given destination before navigating. |
final @NonNull NavOptions.Builder |
<T extends Object> setPopUpTo(Pop up to a given destination before navigating. |
final @NonNull NavOptions.Builder |
setPopUpTo(String route, boolean inclusive, boolean saveState)Pop up to a given destination before navigating. |
final @NonNull NavOptions.Builder |
setRestoreState(boolean restoreState)Whether this navigation action should restore any state previously saved by |
Public methods
build
public final @NonNull NavOptions build()
| Returns | |
|---|---|
@NonNull NavOptions |
a constructed NavOptions |
setEnterAnim
public final @NonNull NavOptions.Builder setEnterAnim(@AnimRes @AnimatorRes int enterAnim)
Sets a custom Animation or Animator resource for the enter animation.
Note: Animator resources are not supported for navigating to a new Activity
| Parameters | |
|---|---|
@AnimRes @AnimatorRes int enterAnim |
Custom animation to run |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
enterAnim |
setExitAnim
public final @NonNull NavOptions.Builder setExitAnim(@AnimRes @AnimatorRes int exitAnim)
Sets a custom Animation or Animator resource for the exit animation.
Note: Animator resources are not supported for navigating to a new Activity
| Parameters | |
|---|---|
@AnimRes @AnimatorRes int exitAnim |
Custom animation to run |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
exitAnim |
setLaunchSingleTop
public final @NonNull NavOptions.Builder setLaunchSingleTop(boolean singleTop)
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 | |
|---|---|
boolean singleTop |
true to launch as single-top |
setPopEnterAnim
public final @NonNull NavOptions.Builder setPopEnterAnim(@AnimRes @AnimatorRes int popEnterAnim)
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 | |
|---|---|
@AnimRes @AnimatorRes int popEnterAnim |
Custom animation to run |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
popEnterAnim |
setPopExitAnim
public final @NonNull NavOptions.Builder setPopExitAnim(@AnimRes @AnimatorRes int popExitAnim)
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 | |
|---|---|
@AnimRes @AnimatorRes int popExitAnim |
Custom animation to run |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
popExitAnim |
setPopUpTo
public final @NonNull NavOptions.Builder <T extends Object> setPopUpTo(boolean inclusive, boolean saveState)
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 extends Object> |
route from a |
boolean inclusive |
true to also pop the given destination from the back stack. |
boolean saveState |
true if the back stack and the state of all destinations between the current destination and |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
popUpToRoute |
|
isPopUpToInclusive |
setPopUpTo
public final @NonNull NavOptions.Builder setPopUpTo(@IdRes int destinationId, boolean inclusive, boolean saveState)
Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.
| Parameters | |
|---|---|
@IdRes int destinationId |
The destination to pop up to, clearing all intervening destinations. |
boolean inclusive |
true to also pop the given destination from the back stack. |
boolean saveState |
true if the back stack and the state of all destinations between the current destination and |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
popUpToId |
|
isPopUpToInclusive |
setPopUpTo
public final @NonNull NavOptions.Builder <T extends Object> setPopUpTo(
@NonNull KClass<@NonNull T> route,
boolean inclusive,
boolean saveState
)
Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.
| Parameters | |
|---|---|
@NonNull KClass<@NonNull T> route |
from the |
boolean inclusive |
true to also pop the given destination from the back stack. |
boolean saveState |
true if the back stack and the state of all destinations between the current destination and |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
popUpToRoute |
|
isPopUpToInclusive |
setPopUpTo
public final @NonNull NavOptions.Builder <T extends Object> setPopUpTo(
@NonNull T route,
boolean inclusive,
boolean saveState
)
Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.
| Parameters | |
|---|---|
@NonNull T route |
route from an Object for destination to pop up to, clearing all intervening destinations. |
boolean inclusive |
true to also pop the given destination from the back stack. |
boolean saveState |
true if the back stack and the state of all destinations between the current destination and |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
popUpToRoute |
|
isPopUpToInclusive |
setPopUpTo
public final @NonNull NavOptions.Builder setPopUpTo(String route, boolean inclusive, boolean saveState)
Pop up to a given destination before navigating. This pops all non-matching destinations from the back stack until this destination is found.
| Parameters | |
|---|---|
String route |
route for destination to pop up to, clearing all intervening destinations. |
boolean inclusive |
true to also pop the given destination from the back stack. |
boolean saveState |
true if the back stack and the state of all destinations between the current destination and |
| Returns | |
|---|---|
@NonNull NavOptions.Builder |
this Builder |
| See also | |
|---|---|
popUpToRoute |
|
isPopUpToInclusive |
setRestoreState
public final @NonNull NavOptions.Builder setRestoreState(boolean restoreState)
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.