The Android Developer Challenge is back! Submit your idea before December 2.

NavArgument.Builder

public static final class NavArgument.Builder
extends Object

java.lang.Object
   ↳ androidx.navigation.NavArgument.Builder


A builder for constructing NavArgument instances.

Summary

Public constructors

NavArgument.Builder()

Public methods

NavArgument build()

Build the NavArgument specified by this builder.

NavArgument.Builder setDefaultValue(Object defaultValue)

Specify the default value for an argument.

NavArgument.Builder setIsNullable(boolean isNullable)

Specify if the argument is nullable.

NavArgument.Builder setType(NavType<?> type)

Set the type of the argument.

Inherited methods

Public constructors

public NavArgument.Builder ()

Public methods

build

public NavArgument build ()

Build the NavArgument specified by this builder. If the type is not set, the builder will infer the type from the default argument value. If there is no default value, the type will be unspecified.

Returns
NavArgument the newly constructed NavArgument.

setDefaultValue

public NavArgument.Builder setDefaultValue (Object defaultValue)

Specify the default value for an argument. Calling this at least once will cause the argument to have a default value, even if it is set to null.

Parameters
defaultValue Object: Default value for this argument. Must match NavType if it is specified.

Returns
NavArgument.Builder This builder.

setIsNullable

public NavArgument.Builder setIsNullable (boolean isNullable)

Specify if the argument is nullable. The NavType you set for this argument must allow nullable values.

Parameters
isNullable boolean: Argument will be nullable if true.

Returns
NavArgument.Builder This builder.

setType

public NavArgument.Builder setType (NavType<?> type)

Set the type of the argument.

Parameters
type NavType: Type of the argument.

Returns
NavArgument.Builder This builder.