NavigationView get/find header layout

前端 未结 7 985
感情败类
感情败类 2020-11-22 02:57

In my NavigationView I have a header layout with id \'viewId\' with active buttons. To setup those buttons, I do the following in activity\'s onPostCreate:

7条回答
  •  心在旅途
    2020-11-22 03:13

    Kotlin version.

    val navView: NavigationView = findViewById(R.id.nav_view)       
    // set User Name
    val headerView: View = navView.getHeaderView(0)
    headerView.txtUserName.text = "User Name Goes here"
    

提交回复
热议问题