且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用带有jetpack导航组件的导航抽屉时如何更改工具栏图标(汉堡图标)

更新时间:2021-11-25 23:02:35

您可以使用 addOnDestinationChangedListener :

You can use the addOnDestinationChangedListener:

    navController.addOnDestinationChangedListener { controller, destination, arguments ->
        if (destination.id == R.id.nav_xxxx){
            supportActionBar?.setHomeAsUpIndicator(R.drawable.xxxx)
        }
    }