Dynamic ActionBar title from a Fragment using AndroidX Navigation

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

    Remove label from graph.xml file

    android:label="fragment_info"
    

    and use old school approach if you want to set title of the fragment dynamically from the fragment itself

    getActivity().setTitle("Your Title");
    

提交回复
热议问题