0
我的activity_main.xml佈局文件指出一個錯誤:解析XML時出錯:未綁定的前綴。不知道爲什麼 - 它似乎與AdView有關。爲什麼我的android佈局XML中存在解析錯誤?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<-- ERROR HERE - error parsing XML: unbound prefix -->
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-xxxxxx/xxxxxx"
ads:adSize="SMART_BANNER"/>
</LinearLayout>
我以前實際上使用這個沒有成功。但你的作品。不知道這是從xmlns來的:googleads =「http://schemas.android.com/apk/res-auto」 – glutz 2014-09-28 00:37:44
@glutz:那也可以,但是你必須使用'googleads'前綴在這種情況下具有屬性;即'googleads:adSize'。事實上,只要你一致,你可以給它任何你喜歡的名字。 – 2014-09-28 06:12:15
@glutz:請不要忘記接受答案,以便其他人也可以從中受益! – 2014-10-05 08:52:45