Android naming convention

android, naming-conventions

Solution

ribot's Android Guidelines are a good example of standard naming conventions:

Naming convention for XML files:

activity_<ACTIVITY NAME>.xml - for all activities
dialog_<DIALOG NAME>.xml - for all custom dialogs
row_<LIST_NAME>.xml - for custom row for listview
fragment_<FRAGMENT_NAME>.xml - for all fragments

Naming convention for component/widget in xml files:

All components for X activity must start with the activity name all component should have prefix or short name like btn for `Button` For example,name for login activity component should be like following.

activity_login_btn_login
activity_login_et_username
activity_login_et_password

Short name of major components:

Button - btn
EditText - et
TextView - tv
ProgressBar - pb
Checkbox - chk
RadioButton - rb
ToggleButton - tb
Spinner - spn
Menu - mnu
ListView - lv
GalleryView - gv
LinearLayout -ll
RelativeLayout - rl

Problem

I am looking for a thorough Android naming convention suggestion. I found a little bit here: http://source.android.com/source/code-style.html#follow-field-naming-conventions which says: - Non-public, non-static field names start with m. - Static field names start with s. - Other fields start with a lower case letter. - Public static final fields (constants) are `ALL_CAPS_WITH_UNDERSCORES`. Yet I am looking for something much more extensive covering all aspects of Android: - how to name layouts and views within, - how to name menus - how to name styles - how to name database tables (singular, plural) and fields within - etc If there is some generally accepted suggestion I would just love to follow that. All SDKs seem to go their own way so I am particular interested in the Android way to do it.

Original source