Ionut Costan
01/20/2020, 6:06 AMandroidx.navigation
component. How could I build a graph and destination programatically?// Obtain its id
val navGraph = NavGraphBuilder(
id = index,
provider = navController.navigatorProvider,
startDestination = homeFragment.id
).build()
val dest = navController.navigatorProvider.getNavigator(FragmentNavigator::class.java)
.createDestination().apply {
id = navHostFragment.id setClassName(HomeFragment::class.qualifiedName!!)
}
navGraph.addDestination(dest)
navController.setGraph(navGraph)
The problem here is that the HomeFragment gets created twice. And I get a strange error: E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.atoss.scsp.android, PID: 9143
java.lang.IllegalStateException: ScrollView can host only one direct child
Which is not the case ... I triple checked