android resolves Android project composition

Source: Internet
Author: User

This article describes the Android project composition, although simple, but must not be overlooked.

When you go from the simple Hello World program to implement some common features, such as drop-down (pull-up) refresh up-to-date (load more), message processing (UI notification update), Viewpager slide effects, start animations, access network files, perform some complex layouts, etc., in to debug some open source projects And finally write your own Android program. When debugging some open source projects, especially those larger open source projects, you will find some "unexpected" situations, whether from the interface, or function, the interface is dazzling, powerful, and because of this, need more resources, such as animation or sound effects, and even use the three-way library, it is necessary to learn more about The Android project poses a problem.

Files/Folders Describe is required

androidmanifest.xml

The application description file, which is required for each Android program, is located in the project's root directory. This file is the total configuration file for the project, documenting the various components used in the application. This file lists the features that the application provides, specifying the service permissions used in the application (such as GPS services, Internet services, SMS services, and so on). The

  • application package name, which is also a unique identifier for the app, and
  • the components that the application contains, such as Activity (that is, <activity.../> element), Servic E, Broadcastreceiver, ContentProvider, etc.;
  • the minimum version compatible with the application, and
  • the application uses the permission claims required by the system, such as <uses-permission Android:name= "Android.permission.INTERNET"/> , allowing Android access to the network.
  • The permissions that other programs need to access the program.

Yes

Gen

Everything that is stored in the directory is automatically generated, and the most important one in this directory is R.java. R.java is a mediation file that is generated automatically when the project is created, which is read-only and cannot be changed. The R.java file is an automatically generated r class, and the R class contains many static classes, and the name of the static class corresponds to a name in Res, which is like a resource dictionary. It contains identifiers for each resource, such as user interface, image, string, etc., and the R class defines the index of all resources for that project.

For example, an XML interface file that has an ID of a TV TextBox control, or android:id= "@+id/tv", can be found by r.id.tv .

With R.java you can quickly find the resources you need, and the compiler will check if the resources in the R.java list are being used, and the unused resources will not be compiled into the software, which will reduce the space occupied by the phone.

Is

Bin

When you use Eclipse development, you don't have to care about the bin directory. If you don't see it in Eclipse, you can view it under Explorer.

Is

Src

Contains all Java source code for the application.

Is

Assets

A collection of folders and files for any other resource. In addition to providing the RES directory to store resource files, Android in the assets directory can also hold resource files, assets directory resource files will not be automatically generated ID R.java, so read assets directory files must specify the path of the file, can be Assetma The Nager class to access these files.

Whether

Res

The resource directory, which contains the resource files in the project and compiles them into the application, is automatically logged when the resource is added to this directory R.java. The Res directory holds the resource files used in all programs. "Resource file" refers to information files, pictures, etc. The directory contains Drawable,anim,layout,values,xml and raw subfolders.

Is

Drawable

Contains the image resources used by the application (*.png, *.jpg). Android 1.5 and the following versions of the directory are drawable,android 1.5 or more versions with 3: DRAWABLE-HDPI, drawable-mdpi and drawable-ldpi.
  • drawable-hdpi high-quality pictures.
  • DRAWABLE-MDPI the quality picture in place.
  • drawable-ldpi low-quality pictures.

Although it is 3 directories, when using R file access, it is the same as Android 1.5 and the following version.

Whether

Anim

A configuration file that contains animation effects used by an application that is described in XML.

Whether

Layout

The layout XML file that contains the application. Instead of using Java encoding to implement an interface layout, you should create a layout that describes the interface through the use of XML.

Whether

Values

Contains constant resources for the application, including strings, styles, and colors. such as in the Strings.xml store a variety of text, as well as the storage of different types of data, such as Arrays.xml, Colors.xml, Styles.xml and so on.

For example, there is a main.xml layout file that can be "@+string/hello" If the Hello constant resource of the Strings.xml file is accessed, and in the program it is accessed in a R.string.hello way. . The general form is:r.< resource type >.< resource Name >.

Whether

Raw

Contains additional data and non-XML data, such as the MP3 file. When you create an Android project using Eclipse, the directory is not created under the Res directory by default and can be created yourself if you want. It can be accessed through I/O streams, such as the built-in audio files in the application, which can be placed under this directory. Access is in r.raw.xxx mode.

Whether

Menu

menu, which mainly places the design of Optionsmenu and Contextmneu menu items. When you create an Android project using Eclipse, the directory is not created under the Res directory by default and can be created yourself if you want.

Whether

Android 4.1

The folder contains the Android.jar file, a Java archive that contains all of the Android SDK libraries (such as views, Controls) and APIs required to build the application. Bind your application to the Android SDK and Android Emulator via Android.jar, which allows you to use all of your Android libraries and packages and enable your application to debug in the right environment.

Is

project.properties

Document the environmental information required in the project, such as the Android version.

For example: Information about the android API android-19 , which indicates that you are using Android 4.4.2. Recently debugging the Oschina project, the project must be android-15 , which is the Android 4.0.3 version.
&NBSP;

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.