📅  最后修改于: 2022-03-11 14:52:34.700000             🧑  作者: Mango
private fun setupNav() {
val navController = findNavController(R.id.nav_host_fragment)
findViewById(R.id.bottomNav)
.setupWithNavController(navController)
navController.addOnDestinationChangedListener { _, destination, _ ->
when (destination.id) {
R.id.mainFragment -> showBottomNav()
R.id.mineFragment -> showBottomNav()
else -> hideBottomNav()
}
}
}
private fun showBottomNav() {
bottomNav.visibility = View.VISIBLE
}
private fun hideBottomNav() {
bottomNav.visibility = View.GONE
}