Stop fragment refresh in bottom nav using navhost

后端 未结 8 1748
夕颜
夕颜 2020-12-31 12:14

This problem has been asked a few times now, but we are in 2020 now, did anyone find a good usable solution to this yet?

I want to be able to navigate using the bott

8条回答
  •  我在风中等你
    2020-12-31 12:58

    The simple solution to stop refreshing on multiple clicks on the same navigation item could be

     binding.navView.setOnNavigationItemSelectedListener { item ->
            if(item.itemId != binding.navView.selectedItemId)
                NavigationUI.onNavDestinationSelected(item, navController)
            true
        }
    

    where binding.navView is the reference for BottomNavigationView using Android Data Binding.

提交回复
热议问题