NavHost
-
Cmn
interface NavHost
NavHostFragment |
NavHostFragment provides an area within your layout for self-contained navigation to occur. |
ComposableNavHostFragment |
A |
DynamicNavHostFragment |
The |
A host is a single context or container for navigation via a NavController.
It is strongly recommended to construct the nav controller by instantiating a NavHostController, which offers additional APIs specifically for a NavHost. The NavHostController should still only be externally accessible as a NavController, rather than directly exposing it as a NavHostController.
Navigation hosts must:
-
Call Navigation.setViewNavController on their root view
-
Route system Back button events to the NavController either by manually calling
NavController.popBackStackor by calling NavHostController.setOnBackPressedDispatcher when constructing the NavController.
Optionally, a navigation host should consider calling:
-
Call
NavHostController.setLifecycleOwnerto associate the NavController with a specific Lifecycle. -
Call
NavHostController.setViewModelStoreto enable usage of NavController.getViewModelStoreOwner and navigation graph scoped ViewModels.
Summary
Public properties |
||
|---|---|---|
NavController |
The |
Cmn
|
Extension functions |
||
|---|---|---|
inline NavGraph |
NavHost.This function is deprecated. Use routes to create your NavGraph instead |
android
|
inline NavGraph |
NavHost.This function is deprecated. Use routes to create your dynamic NavGraph instead |
android
|
inline NavGraph |
NavHost.createGraph(Construct a new |
Cmn
|
inline NavGraph |
NavHost.createGraph(Construct a new |
android
|
inline NavGraph |
NavHost.createGraph(Construct a new |
Cmn
|
inline NavGraph |
NavHost.createGraph(Construct a new |
android
|
inline NavGraph |
NavHost.createGraph(Construct a new |
Cmn
|
inline NavGraph |
NavHost.createGraph(Construct a new |
android
|
Public properties
Extension functions
createGraph
inline fun NavHost.createGraph(
id: @IdRes Int = 0,
startDestination: @IdRes Int,
builder: NavGraphBuilder.() -> Unit
): NavGraph
Construct a new NavGraph
createGraph
inline fun NavHost.createGraph(
id: @IdRes Int = 0,
startDestination: @IdRes Int,
builder: DynamicNavGraphBuilder.() -> Unit
): NavGraph
Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations
createGraph
inline fun NavHost.createGraph(
startDestination: String,
route: String? = null,
builder: NavGraphBuilder.() -> Unit
): NavGraph
Construct a new NavGraph
createGraph
inline fun NavHost.createGraph(
startDestination: String,
route: String? = null,
builder: DynamicNavGraphBuilder.() -> Unit
): NavGraph
Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations
createGraph
inline fun NavHost.createGraph(
startDestination: Any,
route: KClass<*>? = null,
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: NavGraphBuilder.() -> Unit
): NavGraph
Construct a new NavGraph
| Parameters | |
|---|---|
startDestination: Any |
the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added as a |
route: KClass<*>? = null |
the graph's unique route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
createGraph
inline fun NavHost.createGraph(
startDestination: Any,
route: KClass<*>? = null,
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: DynamicNavGraphBuilder.() -> Unit
): NavGraph
Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations
| Parameters | |
|---|---|
startDestination: Any |
the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added as a |
route: KClass<*>? = null |
the graph's unique route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
builder: DynamicNavGraphBuilder.() -> Unit |
the builder used to construct the graph |
createGraph
inline fun NavHost.createGraph(
startDestination: KClass<*>,
route: KClass<*>? = null,
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: NavGraphBuilder.() -> Unit
): NavGraph
Construct a new NavGraph
| Parameters | |
|---|---|
startDestination: KClass<*> |
the starting destination's route from a |
route: KClass<*>? = null |
the graph's unique route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
builder: NavGraphBuilder.() -> Unit |
the builder used to construct the graph |
createGraph
inline fun NavHost.createGraph(
startDestination: KClass<*>,
route: KClass<*>? = null,
typeMap: Map<KType, NavType<*>> = emptyMap(),
builder: DynamicNavGraphBuilder.() -> Unit
): NavGraph
Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations
| Parameters | |
|---|---|
startDestination: KClass<*> |
the starting destination's route from a |
route: KClass<*>? = null |
the graph's unique route from a |
typeMap: Map<KType, NavType<*>> = emptyMap() |
A mapping of KType to custom NavType<*> in the |
builder: DynamicNavGraphBuilder.() -> Unit |
the builder used to construct the graph |