Search code examples
androidlistviewadview

Adview in listview not visible (android)


I am follow google's listview tutorial (http://developer.android.com/resources/tutorials/views/hello-listview.html) and I'm trying to ad an adview to my listview (so that it always stays on top), but I can't get it working. I've tried relativelayout and linear but I can't get it working. I've tried replacing the adview with a button but the button doesn't show up either. Right now I'm using this code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<com.google.ads.AdView android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adUnitId="bannerID"
    ads:adSize="BANNER"
    ads:loadAdOnCreate="true"/>

<ListView android:id="@+id/listView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

</LinearLayout>

This code looks good in the graphical layout but when I run the app it gets covered by the textview in list_item.xml. Anyone have any idea how to get this working? Would really appreciate it.


Solution

  • try to change layout_height in ListView to wrap_content