获取AD浏览报以实际显示 [英] Getting AdView to actually show up
问题描述
我有一个谷歌AD浏览报一个问题...它没有显示出来。我周围挖一个了一会儿,看到有人在这里具有填充的问题,所以我删除了填充和仍然没有运气。
I have a problem with google adview... it's not showing up. I dug around a for a while and saw that people where having issues with padding, so I removed the padding and still no luck.
下面是我的相关舱单数据:
Here is my relevant manifest data:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
<meta-data
android:value="a14d91b10f12454"
android:name="ADMOB_PUBLISHER_ID" />
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
和我的XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/greygradient">
<ScrollView android:id="@+id/scrollView1" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_above="@+id/linearLayout2" android:padding="15dp">
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
<LinearLayout android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent" android:padding="5dp">
<ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageviewdetail"></ImageView>
<TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="5dp" android:id="@+id/textviewdetailname" android:textSize="18dp"></TextView>
</LinearLayout>
<!-- Snip -->
</LinearLayout>
</ScrollView>
<LinearLayout android:id="@+id/linearLayout2" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_alignParentBottom="true" android:orientation="vertical">
<Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="Sign Up!" android:id="@+id/buttondetailsubmit" android:layout_margin="15dp" android:layout_marginTop="10dp" ></Button>
<com.google.ads.AdView android:id="@+id/googleads" android:layout_width="fill_parent" android:layout_height="wrap_content"></com.google.ads.AdView>
</LinearLayout>
最后,运行广告的code:
And finally, the code that is running the ad:
AdView ad = (AdView)findViewById(R.id.googleads);
ad.setEnabled(true);
ad = new AdView(this, AdSize.BANNER, "a14d91b10f12454");
AdRequest r = new AdRequest();
r.setTesting(true);
ad.loadAd(r);
在我的LogCat中,充分显示了我recieving广告。而在AdMob的管理面板,你可以看到有已成功请求..但我不能让愚蠢的观点,以实际显示!
In my LogCat, it shows that I am recieving ads. And in AdMob admin panel you can see that there have been successful requests made.. but I cannot get the stupid view to actually show up!
谁能帮助?
推荐答案
您没有添加AD浏览报给你的布局,当你创建新的AD浏览报以
You aren't adding the AdView to your layout when you create the new AdView with
ad = new AdView(this, AdSize.BANNER, "a14d91b10f12454");
您应该删除从XML AD浏览报,并做到这一点。
You should remove the AdView from the xml and do this.
LinearLayout parent = (LinearLayout) findViewById(R.id.linearLayout2);
AdView ad = new AdView(this, AdSize.BANNER, "a14d91b10f12454");
parent.addView(ad);
AdRequest r = new AdRequest();
r.setTesting(true);
ad.loadAd(r);
这篇关于获取AD浏览报以实际显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!