0
我在使用xml嵌入廣告時遇到問題。我試着用XML,但 做到這一點的告訴我錯誤:錯誤解析XML:綁定PREF上com.google.ads.AdView:Android應用程序中的Admob廣告問題
它這樣做後不顯示,但我看到傳入廣告在我的logCat。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/activity_tuto_layout">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/card_shadow_base"
android:layout_marginTop="@dimen/default_vertical_margin"
android:layout_marginLeft="@dimen/default_horizontal_margin"
android:layout_marginRight="@dimen/default_horizontal_margin"
android:paddingBottom="2dp"
android:id="@+id/tuto_title_card">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/ic_launcher"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="false"
android:layout_alignParentTop="true" />
<TextSwitcher
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tuto_text_switcher"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/imageView">
</TextSwitcher>
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tuto_title_card"
android:layout_above="@+id/closeButton" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/closeButton"
android:layout_below="@+id/pager">
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxxxx" />
</LinearLayout>
<Button
android:id="@+id/closeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/button_close"
android:paddingBottom="12dp"
android:paddingTop="12dp"
android:text="@string/tuto_button_close"
android:textColor="@color/white"
android:textSize="@dimen/home_text_size" />
而且在我的java文件:
AdView adView = (AdView)findViewById(R.id.adView);
AdRequest aRequest = new AdRequest();
aRequest.setTesting(true);
aRequest.addTestDevice("C0150396075730E422F8D1C212A5B658");
adView.loadAd(aRequest);
我在做什麼錯在這裏?
謝謝,覺得這樣.... – saopayne
它doesn」 t顯示,但我碰巧在LogCat上看到它們 – saopayne