Google 致力于为黑人社区推动种族平等。查看具体举措

NavHostController

open class NavHostController : NavController
kotlin.Any
   ↳ androidx.navigation.NavController
   ↳ androidx.navigation.NavHostController

Subclass of NavController that offers additional APIs for use by a NavHost to connect the NavController to external dependencies.

Apps should generally not construct controllers, instead obtain a relevant controller directly from a navigation host via NavHost#getNavController() or by using one of the utility methods on the Navigation class.

Summary

Inherited constants
Public constructors
<init>(@NonNull context: Context)

Construct a new controller for a given Context suitable for use in a NavHost.

Public methods
Unit

Set whether the NavController should handle the system Back button events via the registered OnBackPressedDispatcher.

Unit

Sets the host's LifecycleOwner.

Unit

Sets the host's OnBackPressedDispatcher.

Unit
setViewModelStore(@NonNull viewModelStore: ViewModelStore)

Sets the host's ViewModelStore used by the NavController to store ViewModels at the navigation graph level.

Inherited functions