admob广告没有出现

时间:2011-05-01 03:34:45

标签: android admob ads

我已成功将我的admob广告显示在Google http://code.google.com/mobile/ads/docs/android/fundamentals.html提供的示例代码上,但是当涉及到我自己的应用时,它们就不会显示。

我已经阅读了一些相关问题,但对于我正在使用的LinearLayout来说似乎不是问题。需要注意的一点是,在我的应用程序中,它扩展了ListActivity而不是Activity。

   <?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/com.mypackage.myapp" 
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">
      <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2">

        <com.google.ads.AdView android:id="@+id/adView"                          
            android:layout_width="wrap_content"                          
            android:layout_height="fill_parent"                          
            ads:adUnitId="myadmobid"                          
            ads:adSize="BANNER"/>  
    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2">
        <TextView
            android:id="@+id/hottopictab"
            android:text="Deal"
            android:gravity="center_horizontal|center_vertical"
            android:background="#000000"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:textStyle="bold"
      android:typeface ="sans"
            android:layout_weight="1"/>

        <TextView
            android:id="@+id/newtopictab"
            android:text="()"
            android:gravity="center_horizontal|center_vertical"
            android:background="#000000"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:textStyle="bold"
      android:typeface ="sans"
            android:layout_weight="1"/>

        <TextView
            android:id="@+id/recommendtab"
            android:text=""
            android:gravity="center_horizontal"
            android:background="#000000"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="1"/>

    <ImageButton 
            android:layout_height="fill_parent"
            android:id="@+id/refresh"
            android:background="#000000"
            android:src="@drawable/refresh"     
            android:layout_width="wrap_content" 
            android:layout_marginRight="6dip"    
        /> 


   </LinearLayout>            
   <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="40">

        <ListView
            android:id="@android:id/list"
            android:text="row one"
            android:textSize="15pt"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"/> 

    </LinearLayout>      
</LinearLayout>

5 个答案:

答案 0 :(得分:4)

当您使用应填充广告的活动/方法时,请检查您的logCat。我有一个问题,它不会显示,因为横幅需要50dip垂直空间,我只给它50px(不一样的东西)。 LogCat会给你一个警告,说它无法容纳在请求的空间内。

另外,你在打电话吗

AdView adView = (AdView)this.findViewById(R.id.adView);
        adView.loadAd(new AdRequest());

在你的活动中某处?您必须申请广告,他们不会自动加载。

另外,在广告布局中放置广告,您需要确保您拥有像adMob教程所示的attrs.xml文件。

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="com.google.ads.AdView">
      <attr name="adSize">
          <enum value="1" name="BANNER"/>
          <enum name="IAB_MRECT" value="2"/>
          <enum name="IAB_BANNER" value="3"/>
          <enum name="IAB_LEADERBOARD" value="4"/>
      </attr>
      <attr format="string" name="adUnitId"/>
  </declare-styleable>
</resources>

答案 1 :(得分:2)

问题解决了。这是因为没有足够的空间“没有足够的空间来展示广告!想要:&lt; 480,75&gt;,有:&lt; 336,522&gt;”。当我放大我的模拟器时,它可以工作。

答案 2 :(得分:1)

将admob设置为测试帐户。然后,您将能够看到它是Admob问题还是代码问题。

另外,请检查Logcat - 可能是目前没有任何广告可供您使用。

答案 3 :(得分:0)

几小时前我实施Admob时遇到了这个问题。

我所做的是进入我的admob帐户并设置应用程序为未填充库存提供“内部广告”。

然后,我设置了一个虚假的内部广告(后来我会制作广告来购买应用的非广告版本。)

这意味着如果您从应用中的admob请求广告并且目前没有需求,则会显示您的内部广告。

希望这有帮助

答案 4 :(得分:0)

只等了30分钟为我工作。我重新启动了应用程序,然后出现了添加。