Android coding Specification
I. Android coding specifications
1. the java code does not contain Chinese characters. A maximum of Chinese characters can appear in comments.
2. Local variable name and static member variable name: Only letters can be contained. The first outer Letter of the first letter of the word is uppercase. Other letters are lowercase and start with m;
3. Constant naming: Only letters and _ can be contained. All letters are in uppercase. Words are separated _.
4. Name the id in layout
Naming mode: Module name (package name) _ (layout name) _ layout. xml
The abbreviated view details are as follows:
LayoutView: lv
RelativeView: rv
TextView: TV
ImageView: iv
ImageButton: im
Button: btn
5. Name the view variable in the activity
Naming mode: Logical name + view abbreviation
Suggestion: If the layout file is complex, we recommend that you divide layout into multiple modules. Each module defines a moduleViewHolder whose member variables contain the view
6. id naming in strings. xml
Naming mode: activity name_function module name_logic name/activity name_logic name/common _ logic name
In strings. xml, use activity name annotations to differentiate the file content.
7. Name the image in drawable
Naming mode: activity name_logical name/common _ logical name
8. The size, text size, and color of the control must be extracted separately. Do not directly write the control to the layout file to avoid the troubles caused by later internationalization and adaptation.
Dimens, colors
8. styles. xml: extract the styles that are repeatedly reproduced in layout into general style components and put them in styles. xml;
9. Use layer-list and selector
10. Split images into multiple reusable images as much as possible
11. What the server can achieve is not to be placed on the client.
12. Exercise caution when referencing a third-party library. Avoid using a large third-party library, resulting in a large client package.
13. Handle global application exceptions and errors and send the errors to the server by email
14. process the. 9 Image
15. Exercise caution when using static variables to share Interfaces
16. Log (system name module Name Interface Name, detailed description) needs to have its own Log help class. When a formal package is generated, all logs are closed.
17. unit test (logical test and Interface Test)
18. Do not reuse the handler of the parent class. The handler of the corresponding class should not be used by its subclass. Otherwise, the message. what conflict will occur.
19. Click an event in the activity to implement the onClickListener interface.
20. Use % 1 $ s in strings. xml for character string wildcard
21. If multiple activities contain common UI processing, you can extract a CommonActivity and call the common part for processing. Other activities only need to inherit it.
22. When you use button + activitgroup to implement the tab effect, use Button. setSelected (true) to ensure that the button is in the selected state and make the current activity of activitygroup correspond to the button
23. If a common component is developed, add a prefix to the file name in the drawable/layout/menu/values directory to avoid conflict.
24. data must be validated. For example, if the numeric type is converted to the numeric type, the default value must be set if the conversion fails; whether the server responds to the data effectively or not;
25. If the same client is to be placed in different markets and the data downloaded and used in various markets must be counted
For inconsistent client-end packages, the only difference is versionname, and the APK file name is versionname.apk.
During the upgrade, you must pass your versionCode and versionName to the server. If you need to upgrade, download the apk corresponding to versionName.
About whether to force upgrade:
1). Force upgrade in any situation
2) determine the version of the user and the latest version. if the version is compatible, force upgrade; otherwise, the upgrade is optional;
26. Some buttons should be avoided from repeated clicks
Turn: http://www.cnblogs.com/xiongbo/archive/2011/08/15/2098130.html
I. Android coding specifications
1. the java code does not contain Chinese characters. A maximum of Chinese characters can appear in comments.
2. Local variable name and static member variable name: Only letters can be contained. The first outer Letter of the first letter of the word is uppercase. Other letters are lowercase and start with m;
3. Constant naming: Only letters and _ can be contained. All letters are in uppercase. Words are separated _.
4. Name the id in layout
Naming mode: Module name (package name) _ (layout name) _ layout. xml
The abbreviated view details are as follows:
LayoutView: lv
RelativeView: rv
TextView: TV
ImageView: iv
ImageButton: im
Button: btn
5. Name the view variable in the activity
Naming mode: Logical name + view abbreviation
Suggestion: If the layout file is complex, we recommend that you divide layout into multiple modules. Each module defines a moduleViewHolder whose member variables contain the view
6. id naming in strings. xml
Naming mode: activity name_function module name_logic name/activity name_logic name/common _ logic name
In strings. xml, use activity name annotations to differentiate the file content.
7. Name the image in drawable
Naming mode: activity name_logical name/common _ logical name
8. The size, text size, and color of the control must be extracted separately. Do not directly write the control to the layout file to avoid the troubles caused by later internationalization and adaptation.
Dimens, colors
8. styles. xml: extract the styles that are repeatedly reproduced in layout into general style components and put them in styles. xml;
9. Use layer-list and selector
10. Split images into multiple reusable images as much as possible
11. What the server can achieve is not to be placed on the client.
12. Exercise caution when referencing a third-party library. Avoid using a large third-party library, resulting in a large client package.
13. Handle global application exceptions and errors and send the errors to the server by email
14. process the. 9 Image
15. Exercise caution when using static variables to share Interfaces
16. Log (system name module Name Interface Name, detailed description) needs to have its own Log help class. When a formal package is generated, all logs are closed.
17. unit test (logical test and Interface Test)
18. Do not reuse the handler of the parent class. The handler of the corresponding class should not be used by its subclass. Otherwise, the message. what conflict will occur.
19. Click an event in the activity to implement the onClickListener interface.
20. Use % 1 $ s in strings. xml for character string wildcard
21. If multiple activities contain common UI processing, you can extract a CommonActivity and call the common part for processing. Other activities only need to inherit it.
22. When you use button + activitgroup to implement the tab effect, use Button. setSelected (true) to ensure that the button is in the selected state and make the current activity of activitygroup correspond to the button
23. If a common component is developed, add a prefix to the file name in the drawable/layout/menu/values directory to avoid conflict.
24. data must be validated. For example, if the numeric type is converted to the numeric type, the default value must be set if the conversion fails; whether the server responds to the data effectively or not;
25. If the same client is to be placed in different markets and the data downloaded and used in various markets must be counted
For inconsistent client-end packages, the only difference is versionname, and the APK file name is versionname.apk.
During the upgrade, you must pass your versionCode and versionName to the server. If you need to upgrade, download the apk corresponding to versionName.
About whether to force upgrade:
1). Force upgrade in any situation
2) determine the version of the user and the latest version. if the version is compatible, force upgrade; otherwise, the upgrade is optional;
26. Some buttons should be avoided from repeated clicks
Turn: http://www.cnblogs.com/xiongbo/archive/2011/08/15/2098130.html