Подтвердить что ты не робот

Неожиданный префикс пространства имен "xmlns", найденный для тега LinearLayout

У меня ошибка в следующем XML файле. Msgstr "Неопределенный префикс пространства имен" xmlns ", найденный для tag LinearLayout". Я также пробовал решения, предоставленные в других подобных вопросах, но это не сработало для меня. Такая же ошибка возникает в 3 строках, где используется LinearLayout.

<?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 visually pleasing to have some empty space at the bottom -->

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

</ScrollView>
4b9b3361

Ответ 1

Пожалуйста, попробуйте следующее:

Удалите xmlns:android="http://schemas.android.com/apk/res/android из всех мест, исключая ScrollView. Я считаю, что достаточно сообщить об этом приложению один раз и в самом внешнем макете или представлении XML файла.

Ответ 2

Я столкнулся с этой проблемой несколько раз с различными кодами.

В прошлом коды работали абсолютно нормально, но теперь они показывают эти ошибки....

Я нашел очень простое решение, не требует каких-либо изменений кода (добавление, изменение или удаление).

Перейдите на вкладку "Проект" на вкладке Нажмите на вкладку Выберите "Очистить...." из списка

Вы увидите список всех проектов, открытых в вашем рабочем пространстве.

Вы можете выбрать один проект или все (обычно я делаю "Очистить все проекты" ). Нажмите "ОК". Процесс занимает около 5-7 секунд для около 10 проектов. Все ошибки XMLNS разрешены... Вы должны попробовать это, прежде чем попробовать какое-либо другое решение.... Это похоже на перезапуск системы для ошибки Window, которая устраняет проблемы в 70% случаев...

Вышеупомянутое решение - это скорее временное решение, работающее во всех ситуациях. Чтобы избежать ситуации в будущем, я все xmlns кодов вместе вверху. (может быть дублирующее утверждение, которое может потребоваться для удаления)

У меня возникла эта проблема при интеграции Admob в файл XML.

Ответ 3

В XML файле Android пространство имен Android может:

  • объявляется только
  • объявляется только в верхнем ( "внешнем" ) Android View в иерархии xml

или вы получите сообщение об ошибке при создании проекта. В вашем случае верхнее представление Android - это ScrollView, поэтому держите

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

в ScrollView и удалить его из всех других вложенных Views, включая LinearLayout.

Ответ 4

для людей, которые вдруг видят это сообщение, комментарий от Sudhir должен быть принятым ответом. Английский был не так хорош, я думал: так что если вы боретесь: в eclipse перейдите в project menu click clean... и выберите clean all projects, это приведет к случайному появлению этого сообщения как сообщения в ситуации, когда он отсутствовал до

Ответ 5

Я думаю, что удаление ненужной строки является более подходящим способом, потому что:

1) Очистка проекта разрешит проблему только один раз. И если вы снова запустите проект или переключитесь с другого файла на этот xml файл, он снова покажет ошибку.

2) Что еще более важно, "xmlns:XXX" должно быть свойством первого node.

Ответ 6

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

удалите вышеуказанный тег

и сохраните

<fragment
..........
........
........
......../>

или </fragment>

Ответ 7

Чтобы эта проблема исчезла раз и навсегда без массовых изменений в источнике (что привело бы к шуму для отслеживания версии):

Перейдите на вкладку "Проблемы" - щелкните правой кнопкой мыши сообщение - выберите "Быстрое исправление". Появится окно, где вы можете сказать Eclipse игнорировать эту проблему в проекте (или только в одном файле, если хотите).

После этого XML будет компилироваться нормально.