This is a time to learn about Android, a little more about the directory structure of Android projects developed under Eclipse, and a brief introduction to the directory structure. is the project directory that is expanded under eclipse under the Android project:
Here is a brief introduction to the structure of the directory and its role at all levels:
1. src folder
This folder is for you to write the project's source code, you write in Java code system will automatically put in this folder.
1 Packagecom.example.day04_01;2 Importandroid.app.Activity;3 ImportAndroid.os.Bundle;4 5 Public classMainactivityextendsActivity {//Create a class and then this class inherits the activity
、
6 7 @Override8 protected voidonCreate (Bundle savedinstancestate) {9 Super. OnCreate (savedinstancestate);Ten Setcontentview (r.layout.activity_main); One } A - //Intent Intent = Getintent (); - //String name = Intent.getstringextra ("name"); the //String pwd = Intent.getstringextra ("pwd"); - //Toast.maketext (This, "name =" + name + ", password =" + pwd, 4000). Show (); - -Intent Inten =getintent (); + //User user = Inten. -}
The above code is the first time I created the system in the SRC folder automatically generated a Java file.
2. Gen Catalog
It is the system automatically generate source code directory, automatically generate R.java source file, it is a res directory under the index, according to the Res directory files automatically generated. The Gen directory creates index files for resource data, which, by means of constant internal classes, corresponds the memory address of the data to the name one by one instead of the file path, thus greatly improving the resource location and retrieval rate.
There are 4 static inner classes in R.java, each of which corresponds to a resource under the Res directory, each of which represents a folder, the folder is lowercase, and one by one corresponds. The naming conventions for res are: lowercase english letters, lowercase, horizontal lines, and no uppercase letters.
- 1.PublicStaticFinalClass attr{};//Attribute 2.PublicStaticFinalClass Drawable {//Each one of these records corresponds to: project/res/drawable-* The following picture, the default format is PNGPublicStaticFinalint icon = 0x7f020000;} 3.PublicStaticFinalClass Layout {//There are multiple layout files, all of which begin with lowercase. XML filePublicStaticFinalint main = 0x7f030000;} 4.public static final Span style= "color: #0000ff;" >class string {//1. There is only one String file that corresponds to each record: project/ Each record inside the Res/values/string.xml contains a custom string and value //2. You can also define other properties and attribute values (ARRAYS.XML:COLOR.XML;DIMENS.CML;STYLE.CML) public static final int app_name= 0x7f040001; public static final Span style= "color: #0000ff;" >int helloandroid= 0x7f040000; // project name}
So the R.java internal class and res file correspondence are:
- Picture can draw resources in drawable
- string resource in String
- Layout XML file in layouts
- Control in the ID
- Menu Resources in Menus
3. Android5.0.1
This is the Android development infrastructure package, similar to Rt.jar
4. Android Private Libares
This contains a resource bundle and a build package that can be viewed as a reference
5. Assets
Resource directory, which stores some audio and video images
6. Bin Folder
This is the output folder, generated binary executable directory, generate APK files and so on.
7. Libs folder
Third-party jar package, Baidu positioning and so on.
8. Res folder
It is your resource directory, which contains the resource file of the project you created and compiles it into the application. When you add resources to the resource directory, they are automatically recorded by R.java. The Res directory contains three subdirectories: Drawable,layout,values;
- Drawable: (There are hdpi,xhdpi,xxhdpi,mdpi,ldpi in five formats) contains some of the image formats that you need to use for the application of the project you created.
- Layouts: interface layout file (Main.xml portal layout file, determines the current interface control placement mode, wide color, etc.), main.xml and SRC in the Java file is the corresponding relationship
1<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"2Xmlns:tools= "Http://schemas.android.com/tools"3Android:layout_width= "Match_parent"4android:layout_height= "Match_parent"5android:orientation= "Vertical"6tools:context= "${relativepackage}.${activityclass}" >7 8<Button9Android:id= "@+id/btnlogin"TenAndroid:layout_width= "Wrap_content" Oneandroid:layout_height= "Wrap_content" Aandroid:text= "Login" -/> -<Button theAndroid:id= "@+id/btnregister" -Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" -android:text= "Register" +/> - + A</LinearLayout>
- Values: There is a very important string.xml file (defining resources, storing custom strings and values), in which the data is stored in the form of key-value pairs. This file holds all the specific content that the customer can see, that is, the data (also called the Resource).
9. Androidmainfest.xml: It is the total configuration file of the project, the necessary files in each Android program, located in the root directory of the entire project, documenting the various components used in the application. (The following code will be explained in more detail later)
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "Http://schemas.android.com/apk/res/android" Package= "com.example.day04_01"//The first is the package name, can be modified, here modify SRC inside the package name also to be modifiedAndroid:versioncode= "1"Android:versionname= "1.0" > <uses-sdk//min: Compatible minimum value, target: Highest value android:minsdkversion= "14"android:targetsdkversion= "/>" <Application Android:allowbackup= "true"//automatic BackupAndroid:icon= "@drawable/ic_launcher"//Start iconAndroid:label= "@string/app_name"//app name, which is the name on the phone's desktop, corresponding to string app_name > <Activity Android:name=". Mainactivity "Android:label= "@string/app_name" > <intent-filter> <action android:name= "Android.intent.action.MA In "/> <category android:name=" Android.intent.category.LAUNCHER "/> </intent-filter& Gt </activity> <Activity Android:name=". Loginactivity "Android:label= "@string/title_activity_login" > </activity> </application></manifest>
Onestar
Source: ttp://www.cnblogs.com/jinshuai/
The above is the main directory of Android introduction, if there is insufficient, please advise! Thank you
Talk about Android's engineering directory structure