Android Basics (1)--Structural Analysis of engineering catalogue

Source: Internet
Author: User

Generally speaking, the Android project structure is basically the same, because the Android SDK version used in ADT is 4.4.2, so it is analyzed in this version of the project directory.

This is a complete project directory structure, and we'll analyze the role of each file in turn.

1. SRC Directory

As the name implies, the place where Java source code is stored.

2. Gen Catalog

is a Java auto-generated file that cannot be modified manually.

Among them, ANDROID.SUPPORT.V7 is essentially Java library, usually there will be v4,v13.

Android Support V4: is the earliest (2011.4) implementation of the library. On Android 1.6 (API level 4) or later, it contains most of the functionality relative to V4,v13.

Android Support V7: This package is designed to consider Android 2.1 (API level 7) and above, but V7 is to rely on V4 This package, that is, if you want to use it, two packets are referenced at the same time. The V7 supports the action bar.

Android Support V13: This package is designed for Android 3.2 and later, generally we are not used, tablet development can be used.

Why should we have a support library?

If you are developing an application on a low-version Android platform, and the application wants to use a feature that is higher, you need to use the support library.

How do I use it?

First, make sure the Android support Library is installed;

Then add to the project (e.g. Support-v4 Library)

In ADT, you need to follow these steps:
1. Right-click the current project to find properties
2. Select Java Build Path
3. Select Libraries tab and click on the Add External jars button on the right panel.
4, select the Android-support-v4.jar file, the common path of this file is: your_drive\android-sdks\extras\android\support\v4\ Android-support-v4.jar
5. After completing the Add, select the order and export label to confirm.

Buildconfig.java file : The previous version does not have this file, it is the Android ADT Update added later, its role is the Code of the auxiliary inspection, throughout the project constantly automatic detection.

R.java file : The default is attr, drawable, Layout, string, etc. four static internal classes, each static inner class corresponding to a resource, such as layout static internal class corresponding to the interface file in Layout, Static constants in each of these static inner classes define a resource identifier, such as public static final int main=0x7f030000, and corresponding to the Main.xml file in the layout directory.

   When the developerres/After adding a file of the appropriate type to any subdirectory in the directory,adtr.javaintlayoutpublic Static final class Layoutint constant. On the contrary when we are in res directory delete any one of the files in r.javaadt auto delete.

< Span style= "FONT-SIZE:14PX;" > r.java file in addition to the index function that automatically identifies the resource, there is another major feature, if Res A resource in the directory is not being used in the app, When the application is compiled, the system does not compile the corresponding resources into the application's apk Span style= "FONT-SIZE:14PX;" > in package, this saves android Mobile's resources.

3. Third-party jar packages referenced in the project

4. Assets Directory

For storing external resource files used in the application, programs can read and write files in the directory through I/O streams, and files stored in this directory will be packaged into the release package.

5. Bin directory

The output folder, such as the generated APK file.

androidmainfest.xml: required files that describe the global data in the package, including the components exposed in the packages (activities, services, etc.), their respective implementation classes, Various data and boot locations that can be processed.

An important part of this file is the intent-filters it contains. These filters describe where and when the activity started. Whenever an activity (or operating system) is to perform an action, such as opening a Web page or a contact book, it creates an intent object. It can carry some information describing what you want to do, what data you want to process, the type of data, and some other information. Android compares the information in the intent object and each application exposed Intent-filter to find the most appropriate activity to handle the data and actions specified by the caller.

In addition to declaring your program activities, Content Providers, Services, and intent receivers, you can also specify permissions and instrumentation (security control and testing) In the Androidmanifest.xml file.

  

6. Libs Directory

Used to store third-party libraries.

7. Res Directory

RES/DRAWABLE-HDPI (WVGA, FWVGA): Save high-resolution picture resources.

RES/DRAWABLE-LDPI: Save low-resolution picture resources.

RES/DRAWABLE-MDPI (HVGA): Save a medium-resolution picture resource.

RES/DRAWABLE-XHDPI (720P): Save high-resolution picture resources.

RES/DRAWABLE-XXHDPI (1080P): Save high-resolution picture resources.

A picture resource can use Resources.getdrawable (ID) to obtain a resource type.

Res/layout: Store all layout files, mainly for arranging different display components, to read this configuration in the Android program.

  The default layout file within the layout directory is Activity_main.xml, where you can place different layout structures and controls within the file to meet the needs of the project interface or create a new layout file.

You can see that there are two XML files under layout:

This is because the activity also has its limitations, the same interface on the phone may look good, on the tablet is not necessarily, because the screen is very large, the phone's interface on the tablet may be excessively stretched, the control spacing is too large, and so on. This is a better time to experience the effect of embedding "small activity" in activity, and then each "small activity" can have its own layout. Therefore, our protagonist fragment debut today.

To allow the interface to be better displayed on the tablet, Android introduced the Fragment (fragmentation) feature in version 3.0, which is very similar to activity and can include layouts like activity. Fragment is usually nested in the activity, now imagine this scenario: there are two Fragment,fragment 1 contains a ListView, each line shows the title of a book. Fragment 2 contains TextView and ImageView to show the details and pictures of the book.

Res/values: To store some resource file information for reading text resources, in this folder there are some agreed file names:arrays.xml: Define array data; (You can name it in this XML, Because the last use only uses the name of the array written in this XML file)

Menu: Holds the XML file that defines the Application menu resource.

Values, Values-v11, VALUES-V14: Stores XML files that define multiple types of resources.

Android Basics (1)--Structural Analysis of engineering catalogue

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.