【发布时间】:2016-04-21 04:37:42
【问题描述】:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background1"
tools:context="com.example.flavours.Category" >
<ImageView
android:id="@+id/homeimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:src="@drawable/ice1"/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
每次将构建目标 (6.0) 更改为 (5.0.1) 后,我都没有生成 R (R.id/layout) 的问题。 我已经多次清理项目,当我立即清理项目时,“r”出现错误(R 无法解析为变量)。我还导入了我的(com.example.flavours.R;)但它删除了我按 Ctrl+shift+o。
【问题讨论】:
-
检查 res 文件夹中的所有内容,例如(可绘制、值和布局)等。
-
我只有在我的项目中出现阻止生成 R.java 的错误时才会遇到这种情况;通常是 aapt 工具报告的错误。这可能是 res/ 目录中的无效 XML 或文件名或其他错误。检查 aapt 的输出以查看错误是什么。
标签: android eclipse r.java-file