我试图使用下面的代码显示添加。我得到了错误"AdView缺失了adSize“。
有什么问题吗?
main.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/com.jms.AdmobExample"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="a14f1d807e488dd" />
</LinearLayout>attr.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.google.ads.AdView">
<attr name="adSize">
<enum name="BANNER" value="1"/>
<enum name="IAB_MRECT" value="2"/>
<enum name="IAB_BANNER" value="3"/>
<enum name="IAB_LEADERBOARD" value="4"/>
</attr>
<attr name="adUnitId" format="string"/>
</declare-styleable>
</resources>发布于 2012-02-01 13:57:09
使用这个
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
android:id="@+id/add_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ns:adSize="BANNER"
ns:adUnitId="a14f1d807e488dd" >
</com.google.ads.AdView>
</Linearlayout>发布于 2014-02-04 13:28:42
要使它与Google服务一起工作,请使用:
xmlns:ads="http://schemas.android.com/apk/res-auto“
在XML文件中。
发布于 2012-02-01 14:12:27
您的adsize属性似乎未被识别。
我想说的是,无论您的名称空间属性是问题所在(添加它),您都应该检查是否按预期的那样调用attr.xml "attrs.xml“。
请注意,this说,对于较新版本的AdMob,attrs.xml并不是必需的。
https://stackoverflow.com/questions/9096764
复制相似问题