findViewById returns null on a LinearLayout inside an d view

前端 未结 2 807
日久生厌
日久生厌 2020-12-03 22:07

I cannot figure out mistake here. I may be oevrlooking some thing...

Layout XML:



        
相关标签:
2条回答
  • 2020-12-03 22:32

    try this:

    View v = getlayoutInflater().inflate(((LinearLayout)findViewById(R.id.headerInclude)), null);
    TextView tvTitle = (TextView)  v.findViewById(R.id.tvScreenTitle);
    
    0 讨论(0)
  • 2020-12-03 22:43

    If you set the id attribute for the include element, then that will be the id for the root of the inflated layout. So, instead of looking for a LinearLayout with the id headerLayout look for the id headerInclude(or don't set an id for the include element).

    0 讨论(0)
提交回复
热议问题