Dynamic ActionBar title from a Fragment using AndroidX Navigation

前端 未结 12 1687
别那么骄傲
别那么骄傲 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:12

    On trying the activity's title it seems to override the title for fragment. Being on safe side you must put on onResume.

    override fun onResume() {
        super.onResume()
        activity?.toolbar.title = "YOUR_TITLE_HERE"
    }
    

    it works for me !

    Note : Must have Toolbar Widget in activity

    Add toolbar like this in your activity's xml

    
    
    
        
    
            
    
        
    
        
    
    
    

提交回复
热议问题