Home > Blockchain >  how to make visibility = View.GONE a certain view when launching a certain fragment when using navig
how to make visibility = View.GONE a certain view when launching a certain fragment when using navig

Time:12-16

main_actiity.class

activity_main XML photo

main_fragment.class

fragment_main XML photo

enter image description here

CodePudding user response:

This can be easily done by subscribing to navigation component destination change listener, like this:

navController.addOnDestinationChangedListener { controller, destination, arguments ->
    if(destination.id = R.id.yourMainFragment) {
        // TODO hide/show your view here
    }
}

And then hiding/showing based on destination

  • Related