0
我只是想在我这个代码的应用程序时显示横幅:Android的AdMob的空横幅
XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/welcome"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent"
android:background="#00BFFF"
android:gravity="center_horizontal">
<!--Put form controls here-->
<LinearLayout
android:layout_weight="1" android:layout_gravity="top"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/createevent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/createSportEvent"
android:layout_marginTop="10dp"
android:background="@drawable/blue_button"
/>
<Button
android:id="@+id/joinevent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/joinSportEvent"
android:layout_marginTop="5dp"
android:background="@drawable/blue_button"
/>
<!-- <TextView -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="wrap_content" -->
<!-- android:gravity="center" -->
<!-- android:text="@string/welcome" -->
<!-- android:textColor="#FFFFFF" -->
<!-- android:textSize="30sp" -->
<!-- android:layout_marginTop="60dp" /> -->
</LinearLayout>
<LinearLayout android:layout_weight="4"
android:layout_gravity="bottom"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
>
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/adView"
android:layout_width="200dp"
android:layout_height="300dp"
ads:adUnitId="ca-app-pub-4655928626183886/8875858459"
ads:adSize="BANNER"
/>
</LinearLayout>
</LinearLayout>
JAVA文件:
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice("005d82a31685xxxx");
adView.loadAd(adRequestBuilder.build());
我有谷歌-play-services.jar在我的Java_Buid_Path中。
,并在我的Android_Manifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"android:theme="@android:style/Theme.Translucent" />
我在AdMob广告的网站增加了一个旗帜,以我的移动应用程序来获得adUnitId设置。
我不明白为什么没有显示横幅。
非常感谢您的帮助。
是的,这是一个良好的开端。此外,虽然看起来很明显,但请确保您的设备已连接到互联网。 – 5happy1 2015-01-10 01:02:11
@ 5happy1如果你喜欢它,随时upvote – Mike 2015-01-10 01:44:48
感谢您的答案。我的设备已连接到互联网。我的logcat: – 2015-01-11 22:57:47