[英]I can't Connect navigation drawer items with there related activities and fregmant
我假设您正在使用菜单项,我建议为导航目的地及其相应项目提供相同的 id。
如果 items id 是 nav_home 那么 destionation id 也应该是 navigation.xml 中的 nav_home
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
appBarConfiguration = AppBarConfiguration(setOf(
R.id.nav_home, {*other navigations*}), binding.drawerLayout)
setupActionBarWithNavController(navController, appBarConfiguration)
binding.navView.setupWithNavController(navController)
当你这样设置时,它会自动将目的地连接到项目,你不必手动设置 onclick
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.