ref:http://blog.csdn.net/dianfusoft/article/details/7422540
Can be seen this project by src,gen,android2.3.3 jar package, Assets,bin,res, Androidmanifest.xml,proguard.cfg,project.properties these files (clips), the specific effect is as follows:
Several important documents (clips) are detailed below.
src folder
Expand this folder as shown below
As you can see, this folder is primarily used to store source files
Gen Folder
Expand this folder as follows:
This R.java file is a file that is automatically generated by the system and is very important. The R.java default has a attr,drawable,layout,string of 4 static inner classes, each of which corresponds to a resource. For example, if we add a picture to a project, the project will add a piece of data to the drawable inner class of this class, and if you delete the image, the project will automatically delete the data. Thus, r.java similar to the "registry" in the computer, so the description should not be too much!
So how do we reference the added resources through the R.java file?
(1) In Java programs, we use Java syntax to reference resources
①r.resource_type.resource_name
For example, we want to refer to the project directory under this file
We can get it through r.drawable.ic_launcher because it's a picture file, so we'll register the information in the drawable inner class of the R.java file.
②android. R.resource_type.resource_name
Above this image we can also use Android. R.drawable.ic_launcher get
(2) referencing resources in an XML file
①@[package:]type/name
Use the resources under our own package to omit the package name.
In the XML file, if you want to reference the resources in the Main.xml and androidmainfest.xml files, we can get through the "@drawable/ic_launcher", the expression means, @ Represents the R.java class, drawable represents the static inner class in the R.java class, and/Ic_launcher represents the property drawable in the static inner class Ic_launcher, which corresponds to the picture in the.
② If you access the resources on the Android system, then you need to add the package name "Android:", such as:
Android:textcolor= "@android: color/red"
(3) "@+id/string_name" expression
We can use this expression when we need to add an ID to some components in the layout file. This expression "+" means adding a static variable "String_name" to the internal static class ID of the R.java file, as in the previous code:
[HTML] View Plaincopyprint?<button android:id= "@+id/button" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content"
Now you know what that means, right?
Res folder
Expand this folder as follows:
DRAWABLE-HDPI is used to store high-quality images, drawable-ldpi for low-quality images, drawable-mdpi for medium-quality images.
The Main.xml file below the layout text is the page layout file. In Eclipse we open this file when we select "Graohical Layout" mode to edit the file, we can directly drag a variety of space to quickly edit, select "Main.xml" mode can view the source code, as follows:
Of course, under the Values folder also has an important file String.xml, this file is mainly used to define strings and values, in fact, under this folder can also be stored arrays.xml (used to define the array), Colors.xml (used to define the color and color string values), Dimens.xml (used to set Values), Styles.xml (used to define the style).
Since it is stored value, how do we take the value out of the activity? The author concludes as follows: