2011-09-11 31 views
0

我有这个的manifest.xmlAdMob广告都没有显示出来,但一个简单的按钮是

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="app.fcporto" android:versionCode="1" android:versionName="0.1"> 
<uses-permission android:name="android.permission.INTERNET"></uses-permission> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> 


<application android:icon="@drawable/logo" android:label="@string/app_name"> 

    <activity android:name=".Principal" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity><activity android:name="com.google.ads.AdActivity" 
      android:configChanges="keyboard|keyboardHidden|orientation"/> 
</application></manifest> 

和我的main.xml是

<?xml version="1.0" encoding="utf-8"?> 

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/tabhost" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:orientation="vertical"> 
     <TabWidget android:layout_width="fill_parent" 
      android:layout_height="wrap_content" android:id="@android:id/tabs"></TabWidget> 
     <FrameLayout android:layout_width="fill_parent" 
      android:layout_height="fill_parent" android:id="@android:id/tabcontent"> 

      <LinearLayout android:layout_width="fill_parent" 
       android:layout_height="fill_parent" android:background="#013364" 
       android:id="@+id/tab1"> 
       <ListView android:layout_height="wrap_content" 
        android:layout_width="fill_parent" android:id="@+id/listView2" 
        android:background="#efefef" android:cacheColorHint="#00000000"></ListView> 


      </LinearLayout> 

      <LinearLayout android:layout_width="fill_parent" 
       android:layout_height="fill_parent" android:background="#013364" 
       android:id="@+id/tab2"> 
       <ListView android:layout_height="wrap_content" 
        android:layout_width="fill_parent" android:id="@+id/listView1" 
        android:background="#efefef" android:cacheColorHint="#00000000"></ListView> 
      </LinearLayout> 
      <RelativeLayout android:layout_width="fill_parent" 
       android:layout_height="fill_parent" android:id="@+id/tab3"> 

       <WebView android:layout_width="fill_parent" 
        android:layout_height="fill_parent" android:id="@+id/webview"/> 
      </RelativeLayout> 
      <LinearLayout android:layout_width="fill_parent" 
       android:layout_height="fill_parent" android:background="#013364" 
       android:id="@+id/tab4"> 
       <ListView android:layout_height="wrap_content" 
        android:layout_width="fill_parent" android:id="@+id/listView3" 
        android:background="#efefef" android:cacheColorHint="#00000000"></ListView> 
      </LinearLayout> 


     </FrameLayout> 


    </LinearLayout><LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1" > 


    <com.google.ads.AdView  
     android:id="@+id/ad" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ads:adUnitId="my_unit_id" ads:adSize="BANNER" ads:loadAdOnCreate="true" android:layout_gravity="bottom"/></LinearLayout></TabHost> 

如果我更换

<com.google.ads.AdView  
     android:id="@+id/ad" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ads:adUnitId="my_unit_id" ads:adSize="BANNER" ads:loadAdOnCreate="true" android:layout_gravity="bottom"/> 

由一个简单的按钮,这个工程。我对admob缺少什么?

感谢

回答

1

两种可能性:

  1. 你没有与你的实际AdMob发布商ID替换 “my_unit_id”。
  2. 没有广告可显示。请注意,广告请求的填充率不是100%。检查你的Logcat输出。如果您看到类似“广告请求成功,但由于缺少广告资源而没有返回广告”的消息,则表示没有广告可用。
1

当您全面测试以确保它能正常工作时,您可以打开广告的“testMode”。在开发过程中你会有更好的运气。