【发布时间】:2012-05-05 04:36:42
【问题描述】:
我一直在关注一本关于 Android 的书“Beginning Android Application”。我一直在试图找出一个在视图中显示图像的应用程序。但不幸的是,由于以下错误,我无法运行该应用程序:
[2012-04-24 19:37:33 - Gallery] F:\eclipse workspace\Gallery\res\values
\attrs.xml:2:error: Found text "
[2012-04-24 19:37:33 - Gallery] ​​​​ " where item tag is expected
为方便起见,我在这里给出代码。 main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Bilai"
/>
<Gallery
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView
android:id="@+id/image1"
android:layout_width="320px"
android:layout_height="250px"
android:scaleType="fitXY"
/>
</LinearLayout>
此应用程序需要另一个 xml 文件。它在 res/values 下命名为 attrs.xml。 attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Gallery1" >
<attr name="android:galleryItemBackground" />
</declare-styleable>
</resources>
我认为问题出在 attrs.xml 中,但我不知道发生了什么。因此,R.styleable 也不起作用。请帮忙。提前致谢
【问题讨论】:
-
在
attrs.xml中查找不可打印的字符。如果您已复制粘贴该文件的内容,请尝试删除内容并手动输入内容。 -
谢谢 :) 是的,我从书中复制粘贴了该内容,但无法弄清楚为什么会出现问题。