本文介绍了Android : AdMob onClickListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的 Android 应用程序中显示 AdMob 的 横幅.我希望当用户单击它消失的横幅时.我尝试了代码 AdView.setOnClickListener
但它不起作用...
I display into my android application AdMob's banners. I would like that when the user click on the banner it gone. I have try the code AdView.setOnClickListener
but it not work...
这是代码
private void visual_banner(){
//##### Pubblicità #####
//Create the adView
adView = new AdView(this, AdSize.BANNER, "a14e5bed604ebf8");
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout)findViewById(R.id.layout_ads_streaming);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
adView.destroy();
img.setVisibility(View.VISIBLE);
}
});
adView.loadAd(new AdRequest());
//### FINE PUBBLICITA'
}
推荐答案
我可以帮你添加 AdWhirl.
I can help you with AdWhirl adds.
我已经看到了来源并做了下一步:
I have seen sources and have done next:
public class AdWhirlLayoutCustom extends AdWhirlLayout {
public AdWhirlLayoutCustom(Activity context, String keyAdWhirl) {
super(context, keyAdWhirl);
}
public AdWhirlLayoutCustom(Context context, AttributeSet attrs) {
super(context, attrs);
}
// We intercept clicks
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
boolean result = super.onInterceptTouchEvent(event);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Click!
break;
}
return result;
}
}
这篇关于Android : AdMob onClickListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!