Android 上的空 AdWhirl 布局(不显示广告)
我在将 AdWhirl 集成到我的 Android 应用程序中时遇到一个奇怪的问题。
通过 AdWhirl 连接的网络:
* 迈伦媒体
* AdMob
* InMobi(它给出了无效的适配器错误,但这是一个已知问题,而不是主要问题)
我已经下载并包含了 AdWhirl SDK 3.0.0、各个网络的 jar,并执行了手册中包含的所有步骤(清单文件中的更改) 、lib 等)
我已将 AdWhirl 代码放入我的应用程序中。
作为 AdWhirlLayout 占位符的布局。
<LinearLayout
android:id="@+id/ads"
android:layout_width="fill_parent"
android:layout_height="52dip"
android:layout_weight="0"
android:background="#0f0"/>
广告布局代码:
adLayout = (LinearLayout) findViewById(R.id.ads);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "ad whirl code");
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(UIUtils.dip(320), UIUtils.dip(52));
adWhirlLayout.setBackgroundColor(Color.DKGRAY);
adLayout.addView(adWhirlLayout, adWhirlLayoutParams);
adLayout.invalidate();
我可以看到两种布局均已显示(由于它们具有的颜色)。
我还知道网络连接正确,因为我可以在 logcat
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Showing ad:
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): nid: d10c4fe5e08f469ca1992bfe277902f5
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): name: millennial
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): type: 6
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): key: XXXXX
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): key2:
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Valid adapter, calling handle()
和网络站点上看到这一点 - 我在那里看到广告请求。
但无论如何,布局仍然是灰色的。我很困惑。
I have a strange problem with integrating AdWhirl into my android app.
Networks connected through AdWhirl:
* Mileniall Media
* AdMob
* InMobi (it gives invalid adapter error but thats a known issue and not the main problem)
I've downoaded and included AdWhirl SDK 3.0.0, the jars for respective network and did all the steps included in the manual (changes in manifest file, lib including etc)
And I've put the AdWhirl code into my app.
Layout that is the placeholder for AdWhirlLayout.
<LinearLayout
android:id="@+id/ads"
android:layout_width="fill_parent"
android:layout_height="52dip"
android:layout_weight="0"
android:background="#0f0"/>
Code for ads layout:
adLayout = (LinearLayout) findViewById(R.id.ads);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "ad whirl code");
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(UIUtils.dip(320), UIUtils.dip(52));
adWhirlLayout.setBackgroundColor(Color.DKGRAY);
adLayout.addView(adWhirlLayout, adWhirlLayoutParams);
adLayout.invalidate();
I can see that both of the layouts are shown (due to the color that they have).
I also know that the networks are connected correctly because I can see that in logcat
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Showing ad:
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): nid: d10c4fe5e08f469ca1992bfe277902f5
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): name: millennial
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): type: 6
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): key: XXXXX
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): key2:
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Valid adapter, calling handle()
and on the network sites - I see the ad request there.
But the layout stays gray, no matter what. I'm puzzled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AdWhirl 的文档非常糟糕。尝试这种更简单的方法来扩展 AdWhirl 布局:
您可以简单地通过普通的 XML 布局文件创建布局,而不是通过代码创建布局。不要像他们的说明所建议的那样使用
LinearLayout
(我认为它已经过时了)。相反,只需将此元素放置在布局中您想要横幅的位置即可:说真的,就是这样。确保您的 AdWhirl 密钥也在清单中(在
或
标记内):如果您确实需要以编程方式执行任何操作,可以像往常一样为布局指定一个
id
并使用findViewById
。让我知道这是否有帮助。The documentation for AdWhirl is pretty horrible. Try this much simpler way to inflate the AdWhirl layout:
Instead of creating the layout through code you can simply create it through your normal XML layout file. Don't use the
LinearLayout
like their instructions suggest (I think it's outdated). Instead just place this element in your layout wherever you want the banner to be:Seriously, that's it. Be sure your AdWhirl key is in the Manifest as well (either within the
<activity>
or<application>
tag):If you really need to do anything programmatically you can give the layout an
id
as usual and usefindViewById
. Lemme know if this helps.