Android app structure from scratch

Source: Internet
Author: User

  
 
1. the src directory is the source code directory. All java files that can be modified by users and the java files added by users are saved in this directory.
 
2. The gen directory is a new directory in version 1.5 to save automatically generated java files such as R. java or AIDL files.
 
Note: R. java files (very important)
A) The R. java file is automatically generated by the ADT, which contains reference pointers to resources in the drawable, layout, and values directories. The Android program can directly reference resources in the directory through the R class.
B) The R. java file cannot be manually modified. If a resource file is added or deleted to the Resource Directory, right-click the project name and select Refresh to update the code in the R. java file.
C) The R class contains several internal classes, which correspond to the resource type respectively. Resource IDs are stored in these internal classes. For example, the sub-class drawable represents image resources, the internal static variable icon indicates the Resource Name, and its resource ID is 0x7f020000. Generally, the resource name is the same as the resource file name.
 
3. The android. jar file is a function library file that can be referenced by the Android program. The APIS supported by the platform for Android are included in this file.
 
4. The assets Directory is used to store files in the original format, such as audio files and video files. Resources in this directory cannot be indexed by the R. java file ., Therefore, it can only be read in the form of resource interception. Generally, it is null.
 
 
5. The main. xml file is the interface layout file, which is described in XML language.

<? Xml version = "1.0" encoding = "UTF-8"?>
 
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
 
Android: orientation = "vertical"
 
Android: layout_width = "fill_parent"
 
Android: layout_height = "fill_parent"
 
>
 
<TextView
 
Android: layout_width = "fill_parent"
 
Android: layout_height = "wrap_content"
 
Android: text = "@ string/hello"
 
/>
 
</LinearLayout>

 
6. the Strings. xml file is a string reference in the program.

<? Xml version = "1.0" encoding = "UTF-8"?>
 
<Resources>
 
<String name = "hello"> Hello World, HelloAndroid! </String>
 
<String name = "app_name"> HelloAndroid </string>
 
</Resources>

 
7. AndroidManifest. xml is an Android program declaration file in XML format, which contains important information that must be mastered before the Android system runs the Android program, the information includes the application name, icon, package name, module composition, authorization, and the minimum SDK version. Each Android program must contain an AndroidManifest under the root directory. xml file
 

<? Xml version = "1.0" encoding = "UTF-8"?>
 
<Manifest xmlns: android = "http://schemas.android.com/apk/res/android"
 
Package = "edu. hrbeu. HelloAndroid"
 
Android: versionCode = "1"
 
Android: versionName = "1.0" type = "codeph" text = "/codeph">
 
<Application android: icon = "@ drawable/icon"
 
Android: label = "@ string/app_name">
 
<Activity android: name = ". HelloAndroid"
 
Android: label = "@ string/app_name">
 
<Intent-filter>
 
<Action android: name = "android. intent. action. MAIN"/>
 
<Category android: name = "android. intent. category. LAUNCHER"/>
 
</Intent-filter>
 
</Activity>
 
</Application>
 
<Uses-sdk android: minSdkVersion = "3"/>
 
</Manifest>

 
 
Note: AndroidMainfest. xml file:
1) The root element of the AndroidManifest. xml file is manifest, which contains four attributes: xmlns: android, package, android: versionCode, and android: versionName.
2) xmlns: android defines the Android namespace, the value is http://schemas.android.com/apk/res/android
3) package defines the package name of the application.
4) android: versionCode defines the version number of the application, which is an integer. A larger value indicates that the version is newer, but only used within the application and is not provided to the application user.
5) android: versionName defines the version name of the application. It is a string and is limited to providing users with a version ID.
6) The manifest element can only contain one application element. The application element can declare the four most important components of the Android program, including Activity, Service, BroadcastReceiver, and ContentProvider, the defined attributes will affect all components
7) Row 6th properties android: icon defines the icon of the Android application. @ drawable/icon is a resource reference method, indicating that the resource type is image and the Resource Name Is icon, the corresponding resource file is icon.png In the res/drawabledirectory.
8) the android: label defines the Tag Name of the Android application.
 
8. The default. properties file records settings of the Android project. The file cannot be manually modified. You need to right-click the project name and select "Properties" to modify it.

From: jiahui524 Column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.