I have an include like:
The include layout looks like (te
If you have given the id to the include
element and you have only single view in the included layout (not in any ViewGroup
), in my case AdView
, then use the id of include
element instead of included view.
activity_main.xml
In activity
AdView nullAdView=findViewById(R.id.adView); //this will give null
AdView adView = findViewById(R.id.adsLayout); //this will be AdView
If you do not give id
to include
element then it is ok to use view id
. Also if your view
is inside any ViewGroup
like FrameLayout
then it is ok to use view id
.