Android naming rules

Source: Internet
Author: User

Xml: (all in lower case)

Layout: lAyout _ Module name (package name's last folder name) _ component name (Class Name removes four major component names: for example, MainActivity is main)

View:View _ parent layout component name (layout name) _ component name (all components)

Color. xml:Module name (package name's last folder name) _ Class Name (except four major component names: for example, MainActivity is main) _ component name (all components )_

Color name (English color)

Strings. xml:Module name (package name's last folder name) _ component name (all components) _ Class Name (except four major component names: for example, MainActivity is

Main) _ string name (meaning of the character to be reflected)

...

All follow this structure: module name_class name (except four major component names: for example, MainActivity is main) _ component name (all components) _ (size, color, String, etc.

(Lower case)


Class:

Main module class name:Module name (the last folder Name of the package name, in upper case) + Activity

Sub-module class name (called by the main module, under the same package ):Function name or child component name (child component: for example, one window or one component) + Activity (or

Four major components)

Tool class (Module name + Util ):For example,

Json Conversion Tool: JsonUtil

Database Connection Tool: DBUtil

Service class (Module name + Service): for example,



Variables in class:

Xml component (corresponding to the component id ):Component name (Example 1, 2) _ function name or description name (all lowercase letters indicate an xml component)

Example 1: (if the component has more than two upper-case letters, use the lower-case letters corresponding to the upper-case letters ):

EditText: et_longdistance, et_radius

TextView: TV _longdistance, TV _radius

SharedPreferences: sp_num

Example 2: (if the component has only one uppercase letter, it uses a fixed name, as shown below ):

Button: btn_true

Set Name:

ArrayList (function name or description name + List): personList

HashMap (function name or description name + Map): personMap

SortedSet (feature name or description name + Set): personSet

Array (description or function name + Array): jsonArray

String: jsonString

Temporary variable name (use as few as possible): I, j, m, n,

Constant:Adjective _ noun... (all uppercase)

Methods In class:

Verb + noun [And (conjunction) + Verb + noun] (uppercase letters of each word)




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.