如何在页面上禁用 admob:这就是我在 XML 和主要活动中实现它的方式(当然我有带有 Ad-id 的字符串:
下面的 XML:
<LinearLayout
android:layout_alignParentBottom="true"
android:id="@+id/AdsArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
</LinearLayout>
主要活动如下:
private void loadGoogleAds() {
LinearLayout rootLayout = (LinearLayout) findViewById(R.id.AdsArea);
AdView adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(getString(R.string.ad_unit_id));
rootLayout.addView(adView, 0);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);