2

I was adding some ads to my app with the admod sdk, and I wondered if I can hide the banner after clicking on it, so the user could enjoy the app without ads. I searched it, but I didnt found any proper answer.

I thought about using OnClickListener and OnTouchListener, but neither of those worked.

I added something like this:

adView.setOnTouchListener(new OnTouchListener(){

    public boolean onTouch(View p1, MotionEvent p2)
    {
        // TODO: Implement this method
        return false;
    }

    public boolean onTouch(View v)
    {
        mainLayout.removeView(adView);
        return true;
    }
});
4

2 回答 2

1

查看 AdListener

这些活动可能对您有用

public void onPresentScreen(Ad ad)

在您的应用程序前面创建 Activity 时调用,为用户呈现全屏广告 UI 以响应他们的触摸广告。

public void onDismissScreen(Ad ad)

当使用 onPresentScreen 呈现的全屏 Activity 已被解除且控制权返回到您的应用时调用。公共空白

onLeaveApplication(Ad ad)

当广告触摸将启动新应用程序时调用。

AdMob 广告监听器

于 2012-06-18T13:42:09.077 回答
0

将此添加到我的代码中...效果很好!唯一要做的就是实现 AdListener 和 setAdListener,仅此而已:D

public class MainActivity extends Activity implements AdListener
{

public void onReceiveAd(Ad p1)
{
    // TODO: Implement this method
}

public void onFailedToReceiveAd(Ad p1, AdRequest.ErrorCode p2)
{
    // TODO: Implement this method
}

public void onPresentScreen(Ad p1)
{
    // TODO: Implement this method
}

public void onDismissScreen(Ad p1)
{
    mainLayout.removeView(adView);
}

public void onLeaveApplication(Ad p1)
{
    // TODO: Implement this method
}


@Override
public void onCreate(Bundle savedInstanceState) {   
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//load ad stuff,etc,etc
adView.setAdListener(this);
}
}
于 2012-06-18T14:33:46.110 回答