Naming conventions for Android

I am going to collect my naming conventions for Android here. This may sound like reinventing the wheel, but a cursory glance around will show that there is not much agreement on what should be done. It will be short to start with and hopefully it will improve as I go along. I would of course be much happier to use the official version, but I can't find this. If it shows up I will switch and leave a link here.

Widgets like buttons: Prefix them with a short version of their class - example btn for button. Follow that by camel case for what they are. So btnCancel would be your cancel button. This has the advantage of allowing you to easily filter out all non buttons when you are wiring your xml layout files up to your java.
btn - button
txt - editable text field (EditText)
lbl - non editable text fields (TextView)
tgl - toggle button


String identifiers in strings.xml: use all lower case, separated by underscores. For button labels use btn_ as a prefix.  For example btn_pause is the label for a pause button.

IDs from layout xml files: Same as string identifiers from strings.xml. Example a page title on the user list page would be title_user_list.


Comments

Popular posts from this blog

Building a choropleth map for Irish agricultural data

Early Stopping with Keras

AutoCompleteTextView backed with data from SQLite in Android