java - 在 Eclipse 中将 XML 文件添加到 Android 项目时出错

标签 java android xml eclipse r.java-file

好的,很抱歉问这个问题。我不知道如何解决这个问题。我在 eclipse 中创建一个新项目,将一些 XML 文件放在 res/layout 文件夹中,然后将现有的 java 文件拖放到 src 文件夹中。我尝试通过清理项目来生成 R.java,然后出现以下错误消息:

[2014-02-10 18:28:01 - EventPlanner] W/ResourceType( 7228): ResXMLTree_node size 0xffffffff or headerSize 0xffff is not on an integer boundary.
[2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:6: error: Error: No resource found that matches the given name (at 'id' with value '@id/activity_id').
[2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:7: error: Error: No resource found that matches the given name (at 'id' with value '@id/chk_box').
[2014-02-10 18:28:01 - EventPlanner] E:\Andika\workspaces\EventPlanner\res\layout\activities_list.xml:10: error: Error: No resource found that matches the given name (at 'id' with value '@id/res_text').
.....

并且没有生成 R.java 文件。我试图关闭 eclipse 然后重新打开,但它并没有解决我的问题。我错过了什么?谢谢

编辑:这是我的 XML 布局之一

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:background="@color/black" android:layout_width="fill_parent" android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout android:orientation="vertical" android:paddingLeft="10.0dip" android:paddingTop="10.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:background="@drawable/cell_shape_login_form" android:layout_width="fill_parent" android:layout_height="wrap_content">
            <ImageView android:layout_gravity="center" android:id="@id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_person" />
            <EditText android:textColor="@color/black" android:id="@id/username" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Username" android:ems="20" android:layout_weight="1.0" android:inputType="textPersonName" />
        </LinearLayout>
    </LinearLayout>
    <LinearLayout android:orientation="vertical" android:paddingLeft="10.0dip" android:paddingTop="5.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:orientation="horizontal" android:background="@drawable/cell_shape_login_form" android:layout_width="fill_parent" android:layout_height="wrap_content">
            <ImageView android:layout_gravity="center" android:id="@id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_secure" />
            <EditText android:textColor="@color/black" android:id="@id/password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Password" android:ems="20" android:layout_weight="1.0" android:inputType="textPassword">
                <requestFocus />
            </EditText>
        </LinearLayout>
    </LinearLayout>
    <TextView android:textColor="@color/BlueDefault" android:id="@id/TextView01" android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login as" />
    <LinearLayout android:orientation="vertical" android:paddingLeft="10.0dip" android:paddingTop="5.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <Spinner android:entries="@array/account_type" android:id="@id/spinner1" android:background="@drawable/cell_shape_login_form" android:paddingLeft="10.0dip" android:paddingTop="5.0dip" android:paddingRight="10.0dip" android:paddingBottom="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:prompt="@string/manager" />
    </LinearLayout>
    <LinearLayout android:orientation="horizontal" android:paddingLeft="5.0dip" android:paddingRight="5.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" style="?android:attr/buttonBarStyle">
        <Button android:id="@id/cancel" android:background="@drawable/button_clicked" android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="Cancel" android:layout_weight="0.5" style="?android:attr/buttonBarButtonStyle" />
        <Button android:id="@id/signin" android:background="@drawable/button_clicked" android:layout_width="0.0dip" android:layout_height="wrap_content" android:text="Sign in" android:layout_weight="0.5" style="?android:attr/buttonBarButtonStyle" />
    </LinearLayout>
    <TextView android:textColor="@color/BlueDefault" android:id="@id/signup" android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Don't have any account? click here to sign up" />
</LinearLayout>

最佳答案

在 xml 文件中哪里出现错误。

1) 只需删除整个 id 并使用新的 id 名称重新命名即可。

2) 我看到您在设置样式和背景资源时也遇到了错误。 只需在您的 xml 文件中删除并重新定义它并清理您的项目。

我希望这能解决您的问题......

关于java - 在 Eclipse 中将 XML 文件添加到 Android 项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21676957/

相关文章:

android - 升级到3.0版本时编译报错

android:如何禁用viewpager上的滚动

java - 如何纠正无语法约束错误

java - 增加标签值或添加标签 xSTL

java - 使用 Mockito,如何在没有该类实例的情况下模拟实例方法的返回值?

java - 我可以使用 JNI 在 Java 代码中引用 C++ 对象吗?

java - Android - Google map API 不显示 map

xml - 使用 VBA 获取 XML 中的所有属性和值

java - @SpringBootApplication 如何在 spring boot 中实际工作?

java - 如果上传jsp上存在文件,则重命名