【问题标题】:Android Application:Error "Found text"Android 应用程序:错误“找到文本”
【发布时间】: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 中查找不可打印的字符。如果您已复制粘贴该文件的内容,请尝试删除内容并手动输入内容。
  • 谢谢 :) 是的,我从书中复制粘贴了该内容,但无法弄清楚为什么会出现问题。

标签: android xml image


【解决方案1】:

我认为由于复制/过去方法,您的 attrs.xml 中的每一行之前都有一些字符。

您可以尝试通过将文本光标放在每行的开头并删除以返回上一行来重新格式化您的代码吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-21
    • 2021-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 2023-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多