此XML中的错误:解析XML时出错:未绑定的前缀

时间:2011-04-30 14:01:30

标签: android android-xml

我在这个xml文件中有一个Error parsing XML: unbound prefix

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/sipLabel"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"/>
    <ImageView android:src="@drawable/connected" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_weight="0.35" android:gravity="center"/>
</LinearLayout>

错误在<ImageView>。 可能是什么问题?

非常感谢。

2 个答案:

答案 0 :(得分:5)

您必须将名称空间声明xmlns:android="http://schemas.android.com/apk/res/android"放在layout xml的根元素中:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" [...]

答案 1 :(得分:2)

您需要在最顶层的元素中定义xmlns属性,在本例中为LinearLayout标记。