Is there any way to control views inside NavigationView header?

后端 未结 4 2264
我在风中等你
我在风中等你 2020-12-03 03:07

As the title says, I want to know if there is any way to control views inside the NavigationView header? (Except for adding or removing header.)

For exa

4条回答
  •  攒了一身酷
    2020-12-03 03:31

    Simply try find your view in your activity:

    tvUserName = (TextView) findViewById(R.id.tv_username);
    

    It works for me. My header layout is:

    
    
        
    
    
    

    My NavigationView in Activity Layout is:

    
    

    And BTW, I came across problem when inflating LinearLayout, where layout params are not provided:

    TextView headerView = (TextView) LayoutInflater.from(this).inflate(R.layout.lay_header, null);
    headerView.setText("Your_thoght");
    

    Hope it helps.

提交回复
热议问题