2013-06-24 63 views
0

我是新来的android开发,并正在读它的书(开始android 4开发),同时创建hello世界我陷入了一些错误,首先我解决了他们,但我的应用程序是强制关闭所以我复制粘贴的所有事情,并得到了4个错误: -错误在你好世界xml

Multiple annotations found at this line: - Attribute is missing the Android namespace prefix - Suspicious namespace: should start with http:// - Open quote is expected for attribute "xmlns:android" associated with an element type "LinearLayout". - error: Error parsing XML: not well-formed (invalid token)

Unexpected namespace prefix "android" found for tag TextView

Multiple annotations found at this line: - Unexpected namespace prefix "android" found for tag TextView - Attribute is missing the Android namespace prefix

Unexpected namespace prefix "android" found for tag Button

代码示例

<?xml version ="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/ android” 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_orientation="vertical" 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" /> 

<TextView 
    android:layout_width=”fill_parent” 
    android:layout_height=”wrap_content” 
    android:text=”@string/This is my first Android Application!” /> 

<Button 
    android:layout_width="fill_parent" 
    android:layout_width="wrap_content" 
    android:text="@string/And this is clickable :D" /> 

我不认为有一个在代码中的任何错误:/

+0

是上述xml相同,在书中,我真的怀疑这一点。 – Thalaivar

回答

0

用”并使用ctr + sift + f替换每行代码的引号并保存该文件。

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

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" /> 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/This is my first Android Application!" /> 

<Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/And this is clickable :D" /> 

</LinearLayout> 
+0

我替换了所有的引号,但仍然得到相同的错误:( –

+0

尝试我的代码现在编辑上面的代码 –

1

这是一个复制粘贴问题。将第2行中的引号替换为“并且它应该可以工作

+0

仍然得到相同的错误没有帮助:/ –

+0

删除第2行“res /”和“android”之间的空格 字符串名称不能有空格。对于所有的android:文本属性删除“@字符串/” – Mus

0

替换”与 “” 在你的XML,使之成为有效的XML

0
apk/res/ android 

删除这里的空间,使用

apk/res/android 
0

@string资源应该在字符串中声明。 xml,试试这个!并阅读更多

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

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="hello" /> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="This is my first Android Application!" /> 

    <Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="And this is clickable :D" /> 

    </LinearLayout>