How to set title in app bar with Navigation Architecture Component

前端 未结 12 2011
面向向阳花
面向向阳花 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:22

    NavigationUI.setupActionBarWithNavController(this, navController)
    

    Don't forget to specify android:label for your fragments in your nav graphs.

    To navigate back:

    override fun onSupportNavigateUp(): Boolean {
        return NavigationUI.navigateUp(navController, null)
    }
    

提交回复
热议问题