Android,为什么AdView不显示任何内容?
基于此,我将AdView添加到xml文件中:Android,为什么AdView不显示任何内容?,android,intellij-idea,admob,google-play-services,adview,Android,Intellij Idea,Admob,Google Play Services,Adview,基于此,我将AdView添加到xml文件中: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:orientation="vertical" androi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="@string/api_key_admob"
ads:adSize="BANNER"/>
</LinearLayout>
我在清单文件中添加了以下代码行:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mobilesoft.asia.malaysia_directory"
android:versionCode="10"
android:versionName="2.0">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:allowBackup="true"
android:theme = "@style/Theme.Example">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
...
</application>
</manifest>
...
运行应用程序时,不会显示AdView。我希望在我的浏览页面下方看到它,但没有提示。我怀疑广告:adUnitId=“我的广告单位ID”。当我创建Android应用程序时,AdMob页面中没有广告单元ID。我正在使用AdMob提供的“Publisher-ID”,并将其分配给ads:adUnitId=“Publisher\u-ID”。你认为这是我的问题吗
第二件事,我没有使用AdMob SDK。我已将“google\u play\u services\u lib
”添加到我的项目中,并使用此库而不是AdMob SDK
如有任何建议,将不胜感激。谢天谢地,我的XML设计出了问题 我更改了视图寻呼机的设计,如下代码和AdView在屏幕底部正常工作:
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>