Bradleycorn
03/14/2022, 11:23 PMAndroidViewBinding
to load a FragmentContainerView
with “legacy” fragments (until we can get them converted to compose):
composable(route="my-screen") { AndroidViewBinding(MyFragmentBinding::inflate) }
What I’m struggling with is … when some action is taken in the Fragment (like say a button is clicked), I need to navigate to a new destination (route). How can I do that?Bradleycorn
03/14/2022, 11:27 PMfindNavController()
doesn’t work since the NavController is defined in Compose:
val navController = rememberNavController()
Do I need to provide the navcontroller to the container Activity somehow?
Do I need to provide a callback interface that I can give to the Fragment that I can use to navigate?Bradleycorn
03/14/2022, 11:39 PMAndroidViewBinding(MyFragmentBinding::inflate) {
Navigation.setViewNavController(myFragmentContainer, navController)
}
Trying that …Bradleycorn
03/14/2022, 11:43 PMIan Lake
03/14/2022, 11:55 PMIan Lake
03/14/2022, 11:57 PMIan Lake
03/14/2022, 11:58 PMBradleycorn
03/15/2022, 3:36 PMAndroidViewBinding
to load in the “legacy” Fragments until they can be converted.
It definitely seems plausible, though I’d still have to make updates in the Fragments
(for example, where they use navArgs
to get their arguments bundle)