8.android Coding Specification

Source: Internet
Author: User

1, the Java code does not appear in Chinese, the most comments can appear in Chinese, Chinese unified written in the Strings.xml;

2, local variable name, static member variable name can contain only letters, the first letter of the word capital, the other letters are lowercase
3, the constant name can only contain letters and _, all uppercase letters, between words separated by _
4, name the ID in the layout file
Named mode: The logical name of the view abbreviation _ Module name _view
Common controls are abbreviated as follows
Layoutview:lv_
Relativeview:rv_
Textview:tv_
Imageview:iv_
imagebutton:im_
Button:btn_
Name of ID in 5,strings.xml
Naming pattern: Activity Name _ Function Module Name _ Logical name/activity name _ logical name/common_ logical name
Strings.xml, use activity name comments to separate the contents of the file
6,styles.xml: The continuous style of layout is extracted from the common style generic components, put into the styles.xml;
7, the server can be implemented, do not put on the client;
8, image as many as possible to split into reusable pictures
9, referring to third-party libraries to be cautious, avoid the application of large-capacity third-party libraries, resulting in a very large client package;
10, picture to. 9.png Processing
11, it is prudent to use static variable to realize the sharing between interfaces;
12,log (System name Module name Interface name, detailed description);
13, do not reuse the parent class's handler, corresponding to a class of handler should not let its subclasses use, otherwise it will cause message.what conflict
Using%1 $ s in 14,strings.xml to implement string wildcard
15, if more than one activity contains a common UI processing, then a commonactivity can be refined, the common part is called by it to handle, other activity just inherit it
16, the data must be validated, such as the character type to the digital type, if the conversion failure must have a default value, the service-side response data is valid judgment;

8.android Coding Specification

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.