Android Jetpack Navigation, BottomNavigationView with Youtube or Instagram like proper back navigation (fragment back stack)?

前端 未结 13 2029
误落风尘
误落风尘 2020-12-12 10:25

Android Jetpack Navigation, BottomNavigationView with auto fragment back stack on back button click?

What I wanted, after choosing multiple tabs one after another by

13条回答
  •  生来不讨喜
    2020-12-12 11:11

    Short and good code in Kotlin to connect bottom navigation items with fragments inside navigation graph:

        val navControl = findNavController( R.id.nav_host_frag_main)
        bottomNavigationView?.setupWithNavController(navControl)
    

    *Just consider:Bottom navigation id's & fragments inside navigation graph must have the same id. Also thanks to good explanation from @sanat Answer

提交回复
热议问题