1

In my application i am using Jetpack Navigation with BottomNavigationView. I have like 5 fragments and when i am in Home fragment, i click tab2 item in bottom navigation view and i click tab1 again, it re-creates the fragment.

    val navHostFragment = supportFragmentManager.findFragmentById(
        R.id.nav_host_container
    ) as NavHostFragment

    navController = navHostFragment.navController
    navController.addOnDestinationChangedListener { _, destination, _ ->
        currentNavId = destination.id
    }
    binding.bottomNav.setupWithNavController(navHostFragment.navController)
    binding.bottomNav.apply {
        setupWithNavController(navController)
        setOnItemReselectedListener { }
    }

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.