How to set title in app bar with Navigation Architecture Component

前端 未结 12 1996
面向向阳花
面向向阳花 2020-12-24 11:40

I was trying out Navigation architecture component and is now having difficulties in setting the title. How do I set the title programmatically and also how it works?

<
12条回答
  •  再見小時候
    2020-12-24 12:36

    Another approach could be this:

    fun Fragment.setToolbarTitle(title: String) {
        (activity as NavigationDrawerActivity).supportActionBar?.title = title
    }
    

提交回复
热议问题