Android : AdMob onClickListener


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(;    
        // Add the adView to it    
        // Initiate a generic request to load it with an ad    
        adView.setOnClickListener(new OnClickListener(){

            public void onClick(View arg0) {
        adView.loadAd(new AdRequest());
        //### FINE PUBBLICITA'

Best Solution

Try using AdMob's adListener to listen for events.

public interface AdListener {
  public void onReceiveAd(Ad ad);
  public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error);
  public void onPresentScreen(Ad ad);
  public void onDismissScreen(Ad ad);
  public void onLeaveApplication(Ad ad);

Have your class implement the listener, and then add the listener to the adView:


Implement the onDismissScreen event, which occurs once your app resumes control after handling the ad click. At this point, you can remove the AdView, and you will have gotten credit for the click.

public void onDismissScreen(Ad ad) {
  if (adView != null) {