Dynamic ActionBar title from a Fragment using AndroidX Navigation

前端 未结 12 1703
别那么骄傲
别那么骄傲 2020-12-04 16:16

I am using the new Navigation component from Android Jetpack.

The root Activity setup is quite simple:

override fun onCreate(savedInstanceState: Bund         


        
12条回答
  •  半阙折子戏
    2020-12-04 17:14

    If you use toolbar on setSupportActionBar in Activity and you would like to change its title in fragment, then below code may gonna help you ;)

    (requireActivity() as MainActivity).toolbar.title = "Title here"
    

提交回复
热议问题