eclipse 属性缺少 tools:context 的 Android 命名空间前缀
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18301389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Attribute is missing the Android namespace prefix for tools:context
提问by Xeos
Eclipse editor gives "Attribute is missing the Android namespace prefix" error for the following XML:
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" >
回答by Xeos
It is because xmlns:tools="http://schemas.android.com/tools"
is missing. The code should look like this:
那是因为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" >
回答by Tarsem Singh
add xmlns:tools="http://schemas.android.com/tools"
to your layout
添加xmlns:tools="http://schemas.android.com/tools"
到您的布局
and also note there should be only one namespace for your layout and it should be used in parent layout !
还要注意你的布局应该只有一个命名空间,它应该在父布局中使用!
chanage your code to
将您的代码更改为
<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" >
回答by Jose Kurian
Please add xmlns:tools="http://schemas.android.com/tools" to your code.
请将 xmlns:tools="http://schemas.android.com/tools" 添加到您的代码中。