如何为适配器编写代码以从 adwhirl 中的用户定义网络获取广告
我实现了一个接口,因为它必须在成功和失败时实现 requestAd
、onLeaveApplication
、onPresentScreen
和 onReceiveAd
。我还扩展了 AdwhirlLayout 类。我仅在 Adaptor.java
类 requestAd
中实现了两种方法,仅通过这些行来判断成功和失败,
public void requestAdSuccess() {
// TODO Auto-generated method stub
adWhirlLayout.adWhirlManager.resetRollover();
adWhirlLayout.nextView = adView;
adWhirlLayout.handler.post(adWhirlLayout.viewRunnable);
adWhirlLayout.rotateThreadedDelayed();
}
public void requestAdFail() {
// TODO Auto-generated method stub
adView.setAdListener(null);
adWhirlLayout.rollover();
}
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
public void onReceiveAd(Ad arg0) {
// TODO Auto-generated method stub
}
我每 15 秒刷新一次广告。我根据 adwhirl 示例中的 GoogleAdaptor.java
代码编写了此代码。我还需要在 onLeaveApplication()
中的代码中添加哪些内容?
I implemented one interface in that it has to implement requestAd
on success and failure, onLeaveApplication
, onPresentScreen
, onReceiveAd
. I also extended the AdwhirlLayout class. I implemented only two methods in Adaptor.java
class requestAd
on success and failure only by these lines
public void requestAdSuccess() {
// TODO Auto-generated method stub
adWhirlLayout.adWhirlManager.resetRollover();
adWhirlLayout.nextView = adView;
adWhirlLayout.handler.post(adWhirlLayout.viewRunnable);
adWhirlLayout.rotateThreadedDelayed();
}
public void requestAdFail() {
// TODO Auto-generated method stub
adView.setAdListener(null);
adWhirlLayout.rollover();
}
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
public void onReceiveAd(Ad arg0) {
// TODO Auto-generated method stub
}
I refresh my ad every 15 seconds. I wrote this based on GoogleAdAdaptor.java
code in adwhirl sample. What else do I have to add to the code in onLeaveApplication()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请在此处阅读我对类似问题的回复< /a> 有关实现自定义事件的信息。
从您在此处发布的代码来看,AdWhirlLayout 没有 nextView,因此我认为
adWhirlLayout.nextView = adView;
不起作用。另外,我认为您会想要像这样发布可运行的视图:据我所知,您不会错过 onLeaveApplication 中的任何内容,除非您正在使用的特定广告网络在休假时做了一些特殊的事情。
Please read my response to a similar question here for information about implementing custom events.
From the code you've posted here, AdWhirlLayout doesn't have a nextView so I don't think
adWhirlLayout.nextView = adView;
will work. Also, I think you will want to post the view runnable like this:As far as I know, you're not missing anything in onLeaveApplication, unless the specific ad network you're working with does something special on leave.