NavigationView get/find header layout

前端 未结 7 1098
感情败类
感情败类 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:19

    This is how I did it using ButterKnife and it works for me.

    protected static class HeaderViewHolder {
    
        @BindView(R.id.button)
        Button button;
    
        HeaderViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
    

    and then use this view holder like this :

    View header = navigationView.getHeaderView(0);
    headerViewHolder = new HeaderViewHolder(header);
    

提交回复
热议问题