Android 当admob广告出现时,如何使退出按钮出现?

Android 当admob广告出现时,如何使退出按钮出现?,android,admob,Android,Admob,我放了一个退出按钮,如果点击它可以取消显示广告,但我想让这个按钮在广告出现时出现,在广告消失时消失。我该怎么做? 这是我退出广告的代码: Button exit = (Button) findViewById(R.id.button1); exit.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { LinearL

我放了一个退出按钮,如果点击它可以取消显示广告,但我想让这个按钮在广告出现时出现,在广告消失时消失。我该怎么做? 这是我退出广告的代码:

Button exit = (Button) findViewById(R.id.button1);
        exit.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {


                LinearLayout adscontainer = (LinearLayout) findViewById(R.id.Ll);

                View admobAds = (View) findViewById(R.id.adView1);

                adscontainer.removeView(admobAds);

            }
        });
这是一个xml文件:

  <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/exit" />

<com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/adView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
        ads:adUnitId="a150ce9a2bd8"
        android:layout_column="0"
        android:layout_span="3"
        />

尝试以下方法:


谢谢你的帮助,但我的代码关闭广告是工作。我需要的代码,使退出按钮出现时,广告出现和消失时,广告消失。你能帮我吗?
    AdView adView = (AdView)this.findViewById(R.id.adView1);
    adView.setVisibility(View.INVISIBLE);