I have a custom list view with an adview in it. I get a nullpointer error at atview.setVisibility()
.
.
.
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="my id"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"
ads:refreshInterval="30"
/>
</LinearLayout>
.
setContentView(R.layout.list_content);
adview = (AdView) findViewById(R.id.adView);
adview.setVisibility(View.VISIBLE);
what am i doing wrong?
How do you set the ad unit in the
ListView, like, is it a row in the list, or added as a header/footer?If it is a row, then you should find the id of that row, extract the entire row in a separate view, and using this view find the reference to the
AdViewWith other words, assuming the AdView is always the first element in the list, you would do: