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 problementer image description here enter image description here
How to find out which fragment is currently running
CodePudding user response:
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