0

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

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"
        />
4

1 回答 1

0

试试这种方式:

    AdView adView = (AdView)this.findViewById(R.id.adView1);
    adView.setVisibility(View.INVISIBLE);
于 2013-01-04T10:47:33.463 回答