[英]Bottom Navigation showing in other fragment
I will be glad to finally get a help for this.我很高兴最终能得到这方面的帮助。 I have a single activity application.我有一个单一的活动应用程序。 One of the fragments is also a nav_host(say nav_host2) to other fragments for its bottom navigation.其中一个片段也是其他片段的 nav_host(比如 nav_host2),用于其底部导航。
I want to exit from the from fragment in nav_host two to nav_host1 using deep-linking but notice that the bottom navigation on nav_host2 show on nav_host1 which I do not want as seen in the diagram below.我想使用深度链接从 nav_host 2 中的 from 片段退出到 nav_host1,但请注意 nav_host2 的底部导航显示在 nav_host1 上,如下图所示。
How can I exit the nav_host2 without having the bottom navigation show even-though it is null即使它是 null,如何在没有底部导航显示的情况下退出 nav_host2
use addOnDestinationChangedListener
and hide and show bottomNavigation
with respect to destinationId使用addOnDestinationChangedListener
并隐藏和显示关于destinationId的bottomNavigation
private val AUTH_NAV_GRAPH = arrayOf(
R.id.destination_splash,
R.id.destination_login,
R.id.destination_register,
R.id.destination_forgetpassword
)
val navController = findNavController(this,R.id.nav_host_fragment)// this maybe change
navController.addOnDestinationChangedListener { controller, destination, arguments ->
if(destination.id in AUTH_NAV_GRAPH) {
bottomNavigation?.visibility=View.GONE
} else {
bottomNavigation?.visibility=View.VISIBLE
}
}
where AUTH_NAV_GRAPH
are like fragments with no bottomNavigation
其中AUTH_NAV_GRAPH
就像没有bottomNavigation
的片段
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.