简体   繁体   English

如何检查当前正在运行的片段。 以此为条件

[英]How to check which fragment is running at the moment. To make a condition out of this

I navigate to other fragments using navigation.我使用导航导航到其他片段。 And I want to add a condition that if, for example, (profile fragment) is running, then visibility = GONE for the header. Experts help to solve the problem enter image description here enter image description here我想添加一个条件,例如,如果(配置文件片段)正在运行,则 header 的 visibility = GONE。专家帮助解决问题enter image description here enter image description here

enter image description here在此处输入图像描述

enter image description here在此处输入图像描述

How to find out which fragment is currently running如何找出当前正在运行的片段

hey you can have a look at the below link to find which fragment is currently visible at a certain time嘿,您可以查看以下链接以查找当前在特定时间可见的片段

NavHostFragment navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host);
navHostFragment.getChildFragmentManager().getFragments().get(0);

for more info了解更多信息

Android Navigation Architecture Component - Get current visible fragment Android 导航架构组件 - 获取当前可见片段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM