【问题标题】:" Error parsing XML: unbound prefix " while using AdView使用 AdView 时出现“解析 XML 时出错:未绑定前缀”
【发布时间】:2014-12-15 16:26:35
【问题描述】:

我正在尝试在我的 Android 应用程序中使用 Adview。但现在我遇到了问题。 这是我的 xml 文件中的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/category_page"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="#A0C3FF"
        android:dividerHeight="2dp"
        android:layout_marginBottom="30dp" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_gravity="bottom"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id" >
    </com.google.android.gms.ads.AdView>
</FrameLayout>

</LinearLayout>

相同类型的代码在下一个 xml 文件中运行良好。 但不是在这里。 如果我在任何地方做错了,你能告诉我吗,因为我自己找不到。

【问题讨论】:

    标签: android xml


    【解决方案1】:

    很抱歉,我找到了解决方案。 我错过了包括

    xmlns:ads="http://schemas.android.com/apk/res-auto"
    

    现在代码是这样的

    <?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-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" >
    

    干杯..

    【讨论】:

      猜你喜欢
      • 2023-03-25
      • 2015-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多