【问题标题】:Attribute is missing the Android namespace prefix for tools:context属性缺少工具的 Android 命名空间前缀:上下文
【发布时间】:2013-08-20 12:24:52
【问题描述】:

Eclipse 编辑器为以下 XML 提供“属性缺少 Android 命名空间前缀”错误:

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

【问题讨论】:

    标签: android xml eclipse namespaces


    【解决方案1】:

    这是因为缺少xmlns:tools="http://schemas.android.com/tools"。代码应如下所示:

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

    【讨论】:

      【解决方案2】:

      xmlns:tools="http://schemas.android.com/tools" 添加到您的布局中

      还要注意,您的布局应该只有一个命名空间,并且应该在父布局中使用!

      将您的代码更改为

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

      【讨论】:

        【解决方案3】:

        请将 xmlns:tools="http://schemas.android.com/tools" 添加到您的代码中。

        【讨论】:

          猜你喜欢
          • 2013-11-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-09-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多