安卓:AdMob的onClickListener [英] Android : AdMob onClickListener

查看:197
本文介绍了安卓:AdMob的onClickListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我展示了我的Andr​​oid应用程序的 AdMob的的横幅。我想,当用户点击它消失的旗帜。我已经尝试了code AdView.setOnClickListener ,但它不能正常工作......

编辑:这是code

 私人无效visual_banner(){
// #####Pubblicità#####
        //创建AD浏览报
        AD浏览报=新的AD浏览报(这一点,AdSize.BANNER,a14e5bed604ebf8);
        //查找您的LinearLayout假设它是被赋予了
        //属性机器人:ID =@ + ID / mainLayout
        的LinearLayout布局=(的LinearLayout)findViewById(R.id.layout_ads_streaming);
        // AD浏览报给它添加
        layout.addView(AD浏览报);
        //初始化一个通用的请求与广告加载
        adView.setOnClickListener(新OnClickListener(){

            @覆盖
            公共无效的onClick(查看为arg0){
                adView.destroy();
                img.setVisibility(View.VISIBLE);
            }
        });
        adView.loadAd(新AdRequest());
        // ### FINE PUBBLICITA
}
 

解决方案

我可以帮你AdWhirl补充说。

我见过的来源和做下一:

 公共类AdWhirlLayoutCustom扩展AdWhirlLayout {

公共AdWhirlLayoutCustom(活动的背景下,字符串keyAdWhirl){
    超(背景下,keyAdWhirl);
}

公共AdWhirlLayoutCustom(上下文的背景下,ATTRS的AttributeSet){
    超(背景下,ATTRS);
}

//我们截取点击
@覆盖
公共布尔onInterceptTouchEvent(MotionEvent事件){
    布尔结果= super.onInterceptTouchEvent(事件);
    开关(event.getAction()){

    案例MotionEvent.ACTION_DOWN:
                    //点​​击!
        打破;
    }

    返回结果;
}
 

}

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...

EDIT : this is the code

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'
}

解决方案

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;
}

}

这篇关于安卓:AdMob的onClickListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆