public final class

NavArgument.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.navigation.NavArgument.Builder

Overview

A builder for constructing NavArgument instances.

Summary

Constructors
publicBuilder()

Methods
public NavArgumentbuild()

Build the NavArgument specified by this builder.

public NavArgument.BuildersetDefaultValue(java.lang.Object defaultValue)

Specify the default value for an argument.

public NavArgument.BuildersetIsNullable(boolean isNullable)

Specify if the argument is nullable.

public NavArgument.BuildersetType(NavType<java.lang.Object> type)

Set the type of the argument.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Methods

public NavArgument.Builder setType(NavType<java.lang.Object> type)

Set the type of the argument.

Parameters:

type: Type of the argument.

Returns:

This builder.

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: Argument will be nullable if true.

Returns:

This builder.

See also: NavType.isNullableAllowed()

public NavArgument.Builder setDefaultValue(java.lang.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: Default value for this argument. Must match NavType if it is specified.

Returns:

This builder.

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:

the newly constructed NavArgument.