2011-11-19 58 views
0

我跟随谷歌的列表视图教程(http://developer.android.com/resources/tutorials/views/hello-listview.html),我试图广告adview我的列表视图(以便它始终保持在最前),但我无法得到它的工作。我已经尝试了relativelayout和线性,但我无法得到它的工作。我尝试用按钮替换adview,但该按钮也不显示。现在,我使用此代码:Adview在列表视图不可见(android)

<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的覆盖。任何人有任何想法如何得到这个工作?会真的很感激它。

回答

0

尝试在ListView控件layout_height改变WRAP_CONTENT

+0

试图改变为wrap_content,但它不工作。仍然被list_items中的文本覆盖。谢谢你的建议。 – RaketRagnar

+0

您是否在AndroidManifest.xml中声明com.google.ads.AdActivity?我认为按钮不会因为layout_height而出现,请尝试将它更改为ListView中的wrap_content并添加按钮。 – Style

+0

感谢您的评论! 试过这样做,但按钮仍然不显示。是的,广告显示在其他活动,所以它的工作 – RaketRagnar

0

更改layout_height为wrap_content代替FILL_PARENT

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

谢谢,但它不起作用。屏幕仍然被列表视图覆盖:( – RaketRagnar