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 | |
---|---|
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
Builder
public 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. |
See also:
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. |