├─gen
│ └─com
│ └─iteedu
│ └─helloworld
│ R.java
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.iteedu.helloworld;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
头部的注释说的意思是这个类是由工具aapt从数据源自动生成的,不能手工更改。再看一下R的内容,原来是四个内部类。
从大体上看这和VC++中的资源ID差不多,那就是说还应有对应的资源文件在。如:
public static final int app_name=0x7f040001;应有一个对应的叫app_name的字符串在,因为是在string内部类里的。
同样的:
public static final int main=0x7f030000;应该对应一个叫做main的布局文件在。
这就是我们下面要讲的资源文件。
│ └─com │ └─iteedu │ └─helloworld │ ActivityMain.class │ R$attr.class │ R$drawable.class │ R$layout.class │ R$string.class │ R.class从上可以看出,程序在生成时,R被编译到helloworld文件夹下,所以编程时不用导入就可以用。