NavigationView get/find header layout

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

    For me that was the same situation with 23.1.0, after of update the null pointer exception become. In this case the NavigatorView look like:

    
    

    I tried the solution proposal by ianhanniballake but it does not work. Then I inflated with the sentence:

    LayoutInflater.from(getContext()).inflate(R.layout.nav_header, mNavigationView);
    

    After that, I can find by id all views defined in nav_heardlayout .

提交回复
热议问题