2

我是 android 的新手。我创建了一个项目来检查 android 中可用的文本字段。我在 string.xml 中添加了一些资源并构建了项目。我的 R.java 不是自动生成的。我从项目选项卡中只选择了“自动构建”。我已经多次清理我的项目并重新启动了 eclipse,但我的 r.java 没有生成。我的资源文件夹找不到任何错误。有人可以帮我解决这个问题吗?如果可能的话,还给我一些说明如何使用资源文件夹?请参考下面的我的activity.xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Text_MainActivity"> 

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<EditText
    android:id="@+id/email_address"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="14dp"
    android:ems="10"
    android:hint="@string/email_hint"
    android:inputType="textEmailAddress"/>

<EditText
    android:id="@+id/launch_codes"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/email_address"
    android:layout_below="@+id/email_address"
    android:ems="10"
    android:hint="@string/enter_launch_codes"
    android:imeActionLabel="@string/launch"
    android:inputType="number"/>

<EditText
    android:id="@+id/postal_address"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/launch_codes"
    android:layout_below="@+id/launch_codes"
    android:ems="10"
    android:hint="@string/postal_address_hint"
    android:inputType="textPostalAddress"/>

<AutoCompleteTextView
    android:id="@+id/autocomplete"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/postal_address"
    android:layout_below="@+id/postal_address"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="18dp"
    android:ems="10"
    android:hint="@string-array/countries_array">
</RelativeLayout>

提前致谢

4

2 回答 2

1

这已经被问过很多次了,可能是一个重复的问题。

但同样,您可以尝试清理并重建项目。如果问题仍然存在,请查看 res/ 文件夹,您可能会看到一个红色的 X 图标,显示其中一个 XML 文件已损坏。修复那个 XML,它可能会工作。

顺便说一句,您似乎没有在 xml 中关闭AutoCompleteTextView标记

于 2013-05-20T09:42:50.413 回答
0

在构建项目之前,右键单击 Android 项目,转到 --> Android 工具 ---> 修复项目属性。完成后,右键单击项目并--->构建项目

它可能会解决您的问题。

于 2013-07-29T11:01:00.147 回答