Android string.xml错误
我只是想在这里运行教程,特别是我们添加字符串资源的部分。我已经复制了代码,但是我得到了以下错误Android string.xml错误,android,android-layout,Android,Android Layout,我只是想在这里运行教程,特别是我们添加字符串资源的部分。我已经复制了代码,但是我得到了以下错误 [2012-02-02 20:35:35 - HelloAndoird] /home/slabounty/workspace/HelloAndoird/res/values/strings.xml:2: error: Found text " [2012-02-02 20:35:35 - HelloAndoird] /" where item tag is expected" [2012-02-02
[2012-02-02 20:35:35 - HelloAndoird] /home/slabounty/workspace/HelloAndoird/res/values/strings.xml:2: error: Found text "
[2012-02-02 20:35:35 - HelloAndoird] /" where item tag is expected"
[2012-02-02 20:35:35 - HelloAndoird] /home/slabounty/workspace/HelloAndoird/res/layout/main.xml:3: error: Error parsing XML: not well-formed (invalid token)
下面是strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello Android! I am a string resource!</string>
<string name="app_name">Hello, Android</string>
</resources>
此外,“干净”也不起作用,但这是个好主意。为了安全起见,请将您的
文本视图包装成如下布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
然而,我不明白为什么你的代码会遇到麻烦。但我希望这能解决你的问题 我通过更改
<?xml version="1.0" encoding="utf-8"?>
到
复制了您的代码并使用它与我配合良好。我可以看看您的java文件吗?您是否完成了一个干净的项目?有时候这会解决像这样奇怪的问题。好吧,我不知道,但我又复制了一遍,一切似乎都正常。可能是某种迷失的角色进入了那里或类似的地方?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-16"?>