setupWithNavController method for toolbar no longer available?

二次信任 提交于 2020-04-18 05:44:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!