AdMob的AD浏览报不能在TableLayout现身 [英] AdMob AdView does not show up in TableLayout
问题描述
我已经成功地得到了AdMob的测试广告出现在一个LinearLayout中,但如果我更改为TableLayout,他们不露面。没有错误显示在logcat中。
I have successfully gotten AdMob test ads to show up in a LinearLayout, but if I change to a TableLayout, they do not show up. No errors show in logcat.
这是什么在起作用:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AdRequest request = new AdRequest();
request.setTesting(true);
request.addTestDevice(AdRequest.TEST_EMULATOR);
AdView adview = new AdView(this, AdSize.BANNER, [admob id deleted for posting on stackoverflow]);
// all code before this point is the same in both examples
LinearLayout layout = new LinearLayout(this);
layout.addView(adview);
// all code after this point is the same in both examples
this.setContentView(layout);
adview.loadAd(request);
}
我得到一个可爱的小横幅广告在模拟器的屏幕,上面写着顶成功!现在,您可以通过App银河[谷歌徽标]去旅行。到目前为止,一切都很好。如果我将其更改为一个TableLayout如下但是它没有出现,:
I get a nice little banner ad at the top of the emulator screen that says "Success! Now you are ready to travel through the App Galaxy [Google logo]". So far so good. But it does not appear if I change it to a TableLayout, as follows:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AdRequest request = new AdRequest();
request.setTesting(true);
request.addTestDevice(AdRequest.TEST_EMULATOR);
AdView adview = new AdView(this, AdSize.BANNER, [admob id deleted for posting on stackoverflow]);
// all code before this point is the same in both examples
TableLayout layout = new TableLayout(this);
TableRow row = new TableRow(this);
row.addView(adview);
layout.addView(row);
// all code after this point is the same in both examples
this.setContentView(layout);
adview.loadAd(request);
}
我得到了LogCat中没有任何错误。在这两种情况下(的LinearLayout或TableLayout)所有我得到了AdMob提供的LogCat中为两参考消息:
I get no errors in LogCat. In both instances (LinearLayout or TableLayout) all I get in LogCat from Admob is two informational messages:
广告收到的广告网址:<网址:[URL到应用程序银河'测试广告]>
Ads Received ad url: <"url": "[URL to the 'App Galaxy' test ad]">
广告onRecievedAd()
Ads onRecievedAd()
就是这样。还没有人对没有足够的空间,从其他职位似乎是常见的投诉。我得到的是一个黑色的屏幕。如果我在另一个的TableRow添加之后,含有一个TextView,即TextView的显示向上下方屏幕的顶部50像素,因为如果广告在那里。
That's it. No complaints about not having enough space, which seems common from other posts. All I get is a black screen. If I add in another TableRow afterward, containing a TextView, that TextView shows up 50px below the top of the screen, as if the ad were there.
上的东西任何想法设法得到它的出现?我已经写基于一个TableLayout一个应用程序,如果可能,我宁愿没有重做它的LinearLayout(S)。 。 。
Any ideas on stuff to try to get it to show up? I've already written an app based on a TableLayout and if possible I'd rather not have to redo it in LinearLayout(s) . . .
推荐答案
我猜AD浏览报的家长应具备的特性:
I guess the parent of the AdView should have the property:
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
这篇关于AdMob的AD浏览报不能在TableLayout现身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!