androidx.navigation.fragment


Classes

AbstractListDetailFragment

A fragment supports adaptive two-pane layout.

DialogFragmentNavigator

Navigator that uses DialogFragment.show.

DialogFragmentNavigator.Destination

NavDestination specific to DialogFragmentNavigator.

DialogFragmentNavigatorDestinationBuilder

DSL for constructing a new DialogFragmentNavigator.Destination

FragmentNavigator

Navigator that navigates through fragment transactions.

FragmentNavigator.Destination

NavDestination specific to FragmentNavigator

FragmentNavigator.Extras

Extras that can be passed to FragmentNavigator to enable Fragment specific behavior

FragmentNavigator.Extras.Builder

Builder for constructing new Extras instances.

FragmentNavigatorDestinationBuilder

DSL for constructing a new FragmentNavigator.Destination

NavHostFragment

NavHostFragment provides an area within your layout for self-contained navigation to occur.

Top-level functions summary

FragmentNavigator.Extras
FragmentNavigatorExtras(vararg sharedElements: Pair<ViewString>)

Create a new FragmentNavigator.Extras instance with the given shared elements

Extension functions summary

inline Unit

This function is deprecated. Use routes to create your DialogFragmentDestination instead

inline Unit

Construct a new DialogFragmentNavigator.Destination

inline Unit
<F : DialogFragment, T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>>
)

Construct a new DialogFragmentNavigator.Destination

inline Unit

This function is deprecated. Use routes to create your DialogFragmentDestination instead

inline Unit

Construct a new DialogFragmentNavigator.Destination

inline Unit
<F : DialogFragment, T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>>,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
)

Construct a new DialogFragmentNavigator.Destination

NavController

Find a NavController given a Fragment

inline Unit

This function is deprecated. Use routes to create your FragmentDestination instead

inline Unit

Construct a new FragmentNavigator.Destination

inline Unit
<F : Fragment, T : Any> NavGraphBuilder.fragment(
    typeMap: Map<KTypeNavType<*>>
)

Construct a new FragmentNavigator.Destination

inline Unit

This function is deprecated. Use routes to create your FragmentDestination instead

inline Unit

Construct a new FragmentNavigator.Destination

inline Unit
<F : Fragment, T : Any> NavGraphBuilder.fragment(
    typeMap: Map<KTypeNavType<*>>,
    builder: FragmentNavigatorDestinationBuilder.() -> Unit
)

Construct a new FragmentNavigator.Destination

inline NavArgsLazy<Args>

Returns a Lazy delegate to access the Fragment's arguments as an Args instance.

Top-level functions

FragmentNavigatorExtras

fun FragmentNavigatorExtras(vararg sharedElements: Pair<ViewString>): FragmentNavigator.Extras

Create a new FragmentNavigator.Extras instance with the given shared elements

Parameters
vararg sharedElements: Pair<ViewString>

One or more pairs of View+String names to be passed through to FragmentNavigator.Extras.Builder.addSharedElement.

Extension functions

inline fun <F : DialogFragment> NavGraphBuilder.dialog(id: @IdRes Int): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

inline fun <F : DialogFragment> NavGraphBuilder.dialog(route: String): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
route: String

the destination's unique route

inline fun <F : DialogFragment, T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>> = emptyMap()
): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
<T : Any>

the destination's unique route from a KClass

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

inline fun <F : DialogFragment> NavGraphBuilder.dialog(
    id: @IdRes Int,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

inline fun <F : DialogFragment> NavGraphBuilder.dialog(
    route: String,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
route: String

the destination's unique route

builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

inline fun <F : DialogFragment, T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
<T : Any>

the destination's unique route from a KClass

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

findNavController

fun Fragment.findNavController(): NavController

Find a NavController given a Fragment

Calling this on a Fragment that is not a NavHostFragment or within a NavHostFragment will result in an IllegalStateException

inline fun <F : Fragment> NavGraphBuilder.fragment(id: @IdRes Int): Unit

Construct a new FragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

inline fun <F : Fragment> NavGraphBuilder.fragment(route: String): Unit

Construct a new FragmentNavigator.Destination

Parameters
route: String

the destination's unique route

inline fun <F : Fragment, T : Any> NavGraphBuilder.fragment(
    typeMap: Map<KTypeNavType<*>> = emptyMap()
): Unit

Construct a new FragmentNavigator.Destination

Parameters
<T : Any>

the destination's unique route from a KClass

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

inline fun <F : Fragment> NavGraphBuilder.fragment(id: @IdRes Int, builder: FragmentNavigatorDestinationBuilder.() -> Unit): Unit

Construct a new FragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

builder: FragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

inline fun <F : Fragment> NavGraphBuilder.fragment(route: String, builder: FragmentNavigatorDestinationBuilder.() -> Unit): Unit

Construct a new FragmentNavigator.Destination

Parameters
route: String

the destination's unique route

builder: FragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

inline fun <F : Fragment, T : Any> NavGraphBuilder.fragment(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    builder: FragmentNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new FragmentNavigator.Destination

Parameters
<T : Any>

the destination's unique route from a KClass

typeMap: Map<KTypeNavType<*>> = emptyMap()

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

builder: FragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

@MainThread
inline fun <Args : NavArgs> Fragment.navArgs(): NavArgsLazy<Args>

Returns a Lazy delegate to access the Fragment's arguments as an Args instance.

It is strongly recommended that this method only be used when the Fragment is created by androidx.navigation.NavController.navigate with the corresponding androidx.navigation.NavDirections object, which ensures that the required arguments are present.

class MyFragment : Fragment() {
val args: MyFragmentArgs by navArgs()
}

This property can be accessed only after the Fragment's constructor.