2

我正在测试适用于 Android SDK 的 AdMob。我无法设置,admob:testing="true"因为 admob 属性未知。

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:admob="http://schemas.android.com/apk/res/org.ifies.android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:background="#FF000000"
  android:clickable="true"
>
  <com.admob.android.ads.AdView  
    android:id="@+id/admob" 
    android:visibility="visible"
    android:layout_width="fill_parent" 
    android:layout_height="100px"
    android:background="#FF0000"
    admob:testing="true"
  />
</LinearLayout>

我的 Eclipse 抱怨admob:testing="true"会有一个未知的前缀。有人知道如何解决这个问题吗?

子问题:有人知道如何更改广告的高度吗?它似乎固定为 48 像素,这在任何 DROID 手机上看起来都不是很好......

4

2 回答 2

9

这花了我一段时间才弄清楚,所以我把它贴在这里:

由于 AdMob 4.1 这已经改变,所以之前的答案对于版本 <=4.04 是正确的。现在你需要使用:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 

在新架构中没有您自己的包的位置,也不需要 attrs.xml 文件。

此处的详细信息:http ://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/3b885d3fe5bb21a5?pli=1 (Tim 的帖子,从上数第 8 个)

于 2011-05-23T04:18:10.940 回答
5

可能值得检查错误不是由于文件之外的东西引起的:

确保您在架构 URI 中使用的包名称“org.ifies.android”与 AndroidManifest.xml 中清单元素上的包属性值匹配。

确保 res/values/attrs.xml 具有指定的属性:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="com.admob.android.ads.AdView">
        <attr name="testing" format="boolean" />
        <attr name="backgroundColor" format="color" />
        <attr name="textColor" format="color" />
        <attr name="keywords" format="string" />
        <attr name="refreshInterval" format="integer" />
        <attr name="isGoneWithoutAd" format="boolean" />
    </declare-styleable>
</resources>
于 2010-01-08T11:51:23.663 回答