【问题标题】:Error in xml file (android programming): Unbound Prefix [duplicate]xml文件中的错误(android编程):未绑定前缀[重复]
【发布时间】:2014-02-23 23:18:50
【问题描述】:

我对 android 编程相当陌生,我遇到了一个奇怪的错误,导致我的应用程序无法编译。

这是我的代码

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

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="three" />
</LinearLayout>

它给了我“错误:解析 XML 时出错:未绑定前缀”

【问题讨论】:

    标签: android xml prefix


    【解决方案1】:

    您需要将命名空间声明xmlns:android="http://schemas.android.com/apk/res/android" 添加到您的LinearLayout

    <?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="vertical" >
    
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="three" />
    </LinearLayout>
    

    【讨论】:

    • 谢谢,但我在使用此代码后仍然遇到同样的错误。
    • 那是你的完整 xml 文件吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-17
    • 2021-04-12
    • 2023-03-25
    • 2012-12-22
    相关资源
    最近更新 更多