问题
so previously I had crash with error:
You must call setGraph() before calling getGraph()
then after reading the solution frem here. it is said that I have to use these lines on my gradle
implementation "androidx.navigation:navigation-fragment:2.3.0-alpha02"
implementation "androidx.navigation:navigation-ui:2.3.0-alpha02"
and the error is dissapear. but now I no longer can find setupWithNavController
method. usually I use this line
toolbar.setupWithNavController(navController,appBarConfiguration)
but I no longer find that method. what should I do ?
回答1:
To use any of the NavigationUI Kotlin extension functions, you must use the -ktx
version of the dependencies.
implementation "androidx.navigation:navigation-fragment-ktx:2.3.0-alpha02"
implementation "androidx.navigation:navigation-ui-ktx:2.3.0-alpha02"
来源:https://stackoverflow.com/questions/60598241/setupwithnavcontroller-method-for-toolbar-no-longer-available