Register now for Android Dev Summit 2019!

NavDestinationBuilder

open class NavDestinationBuilder<out D : NavDestination>
kotlin.Any
   ↳ androidx.navigation.NavDestinationBuilder

DSL for constructing a new NavDestination

Summary

Public constructors

<init>(navigator: Navigator<out D>, @IdRes id: Int)

DSL for constructing a new NavDestination

Public methods

Unit
action(actionId: Int, actionBuilder: NavActionBuilder.() -> Unit)

Adds a new NavAction to the destination

Unit
argument(name: String, argumentBuilder: NavArgumentBuilder.() -> Unit)

Add a NavArgument to this destination.

open D

Build the NavDestination by calling Navigator.createDestination.

Unit
deepLink(uriPattern: String)

Add a deep link to this destination.

Properties

Int

CharSequence?

The descriptive label of the destination

Navigator<out D>

Public constructors

<init>

NavDestinationBuilder(navigator: Navigator<out D>, @IdRes id: Int)

DSL for constructing a new NavDestination

Public methods

action

fun action(actionId: Int, actionBuilder: NavActionBuilder.() -> Unit): Unit

Adds a new NavAction to the destination

argument

fun argument(name: String, argumentBuilder: NavArgumentBuilder.() -> Unit): Unit

Add a NavArgument to this destination.

build

open fun build(): D

Build the NavDestination by calling Navigator.createDestination.

deepLink

fun deepLink(uriPattern: String): Unit

Add a deep link to this destination.

In addition to a direct Uri match, the following features are supported:

  • Uris without a scheme are assumed as http and https. For example, www.example.com will match http://www.example.com and https://www.example.com.
  • Placeholders in the form of {placeholder_name} matches 1 or more characters. The String value of the placeholder will be available in the arguments Bundle with a key of the same name. For example, http://www.example.com/users/{id} will match http://www.example.com/users/4.
  • The .* wildcard can be used to match 0 or more characters.
Parameters
uriPattern The uri pattern to add as a deep link

Properties

id

val id: Int

label

var label: CharSequence?

The descriptive label of the destination

navigator

protected val navigator: Navigator<out D>