我在尝试添加 Admob 时遇到布局问题。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads ="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/lined2"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id ="@+id/adview"
android:layout_width="fillparent"
android:layout_height="wrap_content"
ads:adUnitId="My ID"
ad:adSize="BANNER"
ads:testdevices="TEST_EMULATOR"
ads:loadAdOnCreate="true" />
所以错误在这一行:
<com.google.ads.AdView
它说:
Error parsing XML:unbound prefix
我真的搜索了很多帖子,但没有人帮助我...... 我已经添加了 add xmlns:ads .... 但它没有帮助:/ 我忘了某事吗? ?
感谢您的帮助!
最佳答案
您在 adSize
的命名空间中遗漏了 s
。
改变
ad:adSize="BANNER"
到
ads:adSize="BANNER"
关于java - 解析 XML 时出错 : unbound prefix Admob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21753702/