クリックすると広告が消える終了ボタンを配置しましたが、広告が表示されたときにこのボタンを表示し、広告が消えたときに消えるようにしたいです。どうやってやるの?これは広告を終了するための私のコードです:
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"
/>