0

我正在关注谷歌的列表视图教程(http://developer.android.com/resources/tutorials/views/hello-listview.html),我正在尝试在我的列表视图中添加一个广告视图(以便它始终保持在顶部) ,但我无法让它工作。我已经尝试过 relativelayout 和 linear 但我无法让它工作。我尝试用按钮替换 adview,但按钮也不显示。现在我正在使用这段代码:

<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>

这段代码在图形布局中看起来不错,但是当我运行应用程序时,它会被 list_item.xml 中的 textview 覆盖。任何人都知道如何让这个工作?真的很感激。

4

2 回答 2

0

尝试将 ListView 中的 layout_height 更改为 wrap_content

于 2011-11-19T18:02:48.393 回答
0

将 layout_height 更改为 wrap_content 而不是 fill_parent

<ListView android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
于 2011-11-19T18:03:40.840 回答