NavHostFragment.Companion
object NavHostFragment.Companion
Summary
Public methods |
|
---|---|
final @NonNull NavHostFragment |
create(@NavigationRes int graphResId, Bundle startDestinationArgs) Create a new NavHostFragment instance with an inflated NavGraph resource. |
final @NonNull NavController |
findNavController(Fragment fragment) Find a |
Public methods
create
public final @NonNull NavHostFragment create(@NavigationRes int graphResId, Bundle startDestinationArgs)
Create a new NavHostFragment instance with an inflated NavGraph resource.
Parameters | |
---|---|
@NavigationRes int graphResId |
Resource id of the navigation graph to inflate. |
Bundle startDestinationArgs |
Arguments to send to the start destination of the graph. |
Returns | |
---|---|
@NonNull NavHostFragment |
A new NavHostFragment instance. |
findNavController
public final @NonNull NavController findNavController(Fragment fragment)
Find a NavController
given a local Fragment
.
This method will locate the NavController
associated with this Fragment, looking first for a NavHostFragment
along the given Fragment's parent chain. If a NavController
is not found, this method will look for one along this Fragment's view hierarchy
as specified by Navigation.findNavController
.
Parameters | |
---|---|
Fragment fragment |
the locally scoped Fragment for navigation |
Returns | |
---|---|
@NonNull NavController |
the locally scoped |
Throws | |
---|---|
kotlin.IllegalStateException |
if the given Fragment does not correspond with a |