Development of the framework layer of the Android platform (collection, ZT)

Source: Internet
Author: User
Framework development is much more annoying than the application layer. It is enough to make applications in eclipse. You can use controls and other tools in the Android system, or write a class on your own to implement specific functions. For the development of the framework layer, you need to add code, XML, images, ID, and other data to the source code. This ID can be done with great effort. During the first one and a half months of the project, I have tried a lot and shared my experience. There is very little development information about the framework layer on the internet, mostly on your own.

The most effective method is to analyze the android source code to see how Google implements a class and its hierarchy. I am mainly looking at the code in widgets and apps, but nothing else is involved. For example, view, viewgroup, activity, and activitythread are all very important classes and classes with a large amount of code. I just went through it and haven't analyzed it carefully.

What I have made a lot of effort is the role of several files in values under the Resource folder.

Attrs. XML defines the attributes of a class to be referenced in an XML file. In other words, it specifies the values of the variables (that is, the actual roles of the attributes) in the class. These attributes are used in the class constructor. If you have read one or two source codes, the typedarray In the constructor is actually an attribute array. The members of the array will be assigned to the class members to complete the XML initialization. Class constructor generally has three, one is class (context), this is used to create a class in the code, so it only contains one context; Class (context, attrs) and class (context, attrs, defstyle) are used to create classes from XML.

Styles. xml contains the "styles" of each control. styles are composed of attributes. When editing an XML file, the attributes set by different classes have the same and different attributes, which are controlled by styles. For details, see the contents of styles. xml.

Themes. XML is actually a style, but it is applicable to a wider range. I have not studied themes. XML based on others' opinions on the Internet.

IDs. XML is a public ID, that is, the ID visible to the application layer. ID is a parameter required to obtain the object in XML, that is, object = findviewbyid (R. id. id_name in id_name. These values can be referenced by Android. R. ID in the code.

Public. xml describes a 32 id value specified by ATTR, ID, and drawable. This value is used in the current. xml file.

After we modify public. XML, execute the make Update-API command to add the changes to current. xml. Because these values are placed on different segments by type, the same type must be stored continuously. If the id value is not specified, the system automatically calculates the next value.

Method to add an ID: 1) Add a public ID item to IDs. XML, and add the corresponding ID item to public. xml. This method is not compatible with other versions.

2) Add a public ID item to IDs. XML, and add a line of comment before each item. This eliminates the need to add corresponding items to public. xml. The source code is in the form of/** @ hide */, so that no corresponding segment exists in current.

3) In self-written XML, the Android: Id = "@ + ID/id_name" format is the same as in eclipse, after searching, you will find that android source code is also used in this way, IDs. XML and public. you don't need to modify the XML, so I'm not sure about compatibility.

The above hopes will help you.

 

Http://tech.it168.com/a2010/1108/1122/000001122996.shtml

 

Related Article

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.