【发布时间】:2015-07-01 17:14:29
【问题描述】:
您好,我正在尝试在片段中显示 adview,但我没有得到任何结果,它只显示空白区域,在活动中它工作正常,
对于片段我写了如下代码:
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/innerbg"
xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@null"
android:listSelector="@android:color/transparent"
android:layout_above="@+id/adView"
android:layout_alignParentTop="true"/>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/adunit_id_home"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
在片段中:
AdView adViewHome = (AdView) rootView.findViewById(R.id.adViewHome);
AdRequest adRequest = new AdRequest.Builder().build();
adViewHome.loadAd(adRequest);
【问题讨论】:
-
为什么它被否决了?我可以知道原因吗?
-
我不知道为什么这些人对这个问题投了反对票,如果有任何问题,请告诉我,以便以后不再重复。不通知投反对票是不对的,必须纠正新手
标签: android android-fragments adsense adview