首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为标记LinearLayout找到意外的命名空间前缀"xmlns“

为标记LinearLayout找到意外的命名空间前缀"xmlns“
EN

Stack Overflow用户
提问于 2013-02-17 08:12:42
回答 5查看 64.9K关注 0票数 51

我在下面的xml文件中遇到错误。为标记LinearLayout找到意外的命名空间前缀"xmlns“。我也尝试了其他类似问题中提供的解决方案,但它对我不起作用。在使用LinearLayout的3行中出现了相同的错误。

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/menu_top_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/name_version"
            android:textColor="@color/black"
            android:textSize="20sp" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
        </LinearLayout>

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="30px" >
        </FrameLayout>

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal" >

                <Button
                    android:id="@+id/start_stop_button"
                    android:layout_width="74dp"
                    android:layout_height="74dp"
                    android:text="@string/start_server" />

                <Button
                    android:id="@+id/instructions"
                    android:layout_width="120dp"
                    android:layout_height="74dp"
                    android:text="@string/instructions_label" />

                <Button
                    android:id="@+id/setup"
                    android:layout_width="74dp"
                    android:layout_height="74dp"
                    android:text="@string/setup_label" />
            </LinearLayout>
        </LinearLayout>

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="30px" >
        </FrameLayout>

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#666666" >
        </FrameLayout>

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="10px" >
        </FrameLayout>

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="2" >

            <TableRow>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    android:text="@string/server_status"
                    android:textColor="@color/black"
                    android:textSize="16sp" />
                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/server_status"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/unknown"
                    android:textColor="@color/black"
                    android:textSize="16sp" />
            </TableRow>
        </TableLayout>

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="10px" >
        </FrameLayout>

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#666666" >
        </FrameLayout>

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="10px" >
        </FrameLayout>

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="2" >

            <TableRow>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    android:text="@string/my_url_is"
                    android:textColor="@color/black"
                    android:textSize="16sp" />
                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/ip_address"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/no_url_yet"
                    android:textColor="@color/black"
                    android:textSize="16sp" />
            </TableRow>

            <TableRow>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    android:text="@string/wifi_status"
                    android:textColor="@color/black"
                    android:textSize="16sp" />
                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/wifi_status"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/unknown"
                    android:textColor="@color/black"
                    android:textSize="16sp" />
            </TableRow>

            <TableRow>

                <TextView
                    android:id="@+id/last_error_label"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    android:text="@string/last_error"
                    android:textSize="16sp"
                    android:visibility="gone" />
                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/last_error"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/unknown"
                    android:textColor="#ff0000"
                    android:textSize="16sp"
                    android:visibility="gone" />
            </TableRow>
        </TableLayout>

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="10px" >
        </FrameLayout>

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#666666" >
        </FrameLayout>

        <!--
          <TextView android:id="@+id/proxy_header"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="@string/proxy_experimental"
        android:textSize="16sp"
        />
        -->

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="2" >

            <TableRow>

                <!--
                 <TextView
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/proxy_status"
                android:textSize="16sp"
                android:gravity="left"
                />
                -->
                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />
            </TableRow>

            <TableRow>

                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />
            </TableRow>

            <TableRow>

                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />
            </TableRow>

            <TableRow>

                <!-- A small spacer between the columns -->

                <FrameLayout
                    android:layout_width="3sp"
                    android:layout_height="wrap_content" />
            </TableRow>
        </TableLayout>

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:background="#666666" >
        </FrameLayout>

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:background="#666666" >
        </FrameLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:visibility="gone" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/server_log"
                android:textColor="#ffffff" />

            <CheckBox
                android:id="@+id/server_log_checkbox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="false" />
        </LinearLayout>

        <TextView
            android:id="@+id/server_log"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#333333" />

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:background="#666666"
            android:visibility="gone" >
        </FrameLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:visibility="gone" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/session_monitor"
                android:textColor="#ffffff"
                android:visibility="gone" />

            <CheckBox
                android:id="@+id/session_monitor_checkbox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="false"
                android:visibility="gone" />
        </LinearLayout>

        <TextView
            android:id="@+id/session_monitor"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#333333"
            android:visibility="gone" />

        <!-- A horizontal line -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:background="#666666" >
        </FrameLayout>

        <!-- It's visually pleasing to have some empty space at the bottom -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="15dp" />
    </LinearLayout>

</ScrollView>
EN

回答 5

Stack Overflow用户

发布于 2013-03-25 03:56:16

我在不同的代码中多次遇到这个问题。

代码在过去运行得非常好,但现在它们显示了这些错误...

我找到了一个非常简单的解决方案,不需要任何代码更改(添加、编辑或删除)。

转到选项卡上的项目选项卡单击选项卡选择“Clean...”从列表中

您将看到在工作区中打开的所有项目的列表。

您可以选择一个项目,也可以选择所有项目(我通常选择“清理所有项目”)。单击Ok。对于大约10个项目,这个过程大约需要5-7秒。所有的XMLNS错误都已解决...在尝试任何其他解决方案之前,您应该先尝试此方法...这就像重新启动系统的Window错误,解决问题的70%的时间……

上面的解决方案更像是一个在所有情况下都能工作的临时解决方案。为了避免将来出现这种情况,我将所有的xmlns代码放在顶部。(可能存在需要删除的重复语句)

在XML文件上集成Admob时,我遇到了这个问题。

票数 43
EN

Stack Overflow用户

发布于 2013-04-09 17:11:09

对于突然看到这条消息的人,来自Sudhir的评论应该是被接受的答案。英语不是很好,我想:所以,如果你在努力:在eclipse中,进入project菜单,点击clean...,然后选择clean all projects,这将会在之前丢失的情况下消除随机出现的消息

票数 4
EN

Stack Overflow用户

发布于 2014-03-20 10:05:28

我认为删除不需要的行是更合适的方法,因为:

1)清理项目只能解决一次问题。如果您再次启动项目或从另一个文件切换到此xml文件,它将再次显示错误。

2)更重要的是,"xmlns:XXX“应该是第一个节点的属性。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14916638

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档