Android Reserved Word List

I am currently developing a development interface for another Android application, and it seems I am trying to use reserved words for resources (be it drawings and layouts). As far as I know, there are a number of rules that you need to know:

  • Uppercase letters are prohibited.
  • No characters other than underscores.
  • No numbers

Appart from the (please correct me if I am wrong). I think you cannot use any reserver words from JAVA that after a little google search look like this:

enter image description here

So, my question will be, if somewhere in the documents that I could not find, which explains in detail what we can and can not use for resource names. This is right after reading the resource page, so it's possible that I'm just useless in reading.

Reserved Word Source

+8
java android resources reserved-words
source share
4 answers

As far as I know, there are a number of rules that you need to know:

Uppercase letters are prohibited.

AFAIK, this is not the rule. The convention is to use all lowercase letters, but the mixed case worked.

NOTE. . In layouts you can use only lowercase letters (az), numbers (0-9) and underscore (_).

No characters other than underscores

Correctly. More specifically, the name must be a valid Java data member name that restricts you to letters, numbers, and underscores, and it cannot begin with a number.

No numbers

This is not a rule, although your name cannot begin with a number, as indicated above.

Appart from the (please correct me if I am wrong). I think you cannot use any reserver words from JAVA that after a little google search look like this:

This is because reserved words are not valid Java data name names.

So my question will be if there is somewhere in the documents that I did not find that explains in detail what we can and cannot use for resource names

Apparently not.

+9
source share

Well, my answer will consist of several pages where you can find what you need.

1.- First, I would recommend that you read the conventions that Oracle recommends for java

NOTE: in particular, the section " Naming Conventions " (which is what most of the other answers have), after which I suggest you read " Java Languages ​​Keywords , because you cannot use any of these words, BUT remember that JAVA CASE-SENSITIVE , therefore, if you write "Abstract" instead of "abstract", then everything is in order, but, of course, it can confuse someone later (maybe yourself).

2.- And last but not least, you can read the " Code Style Rules ", these are conventions that contribute to the Android source code you need to apply to their code in order to be accepted.

If you follow these rules, your code will not only be valid (of course, this is important), it will be more readable for you and others, and if another person needs to make some changes later, it will be easier than if you started typing random ones names like "x1, x2, X1, _x1, etc."

OTHER USEFUL ARTICLE :

If you are starting your application, this article will be very useful for you, this explains why using setters and getters in exaggerated form is a very bad practice, they should be ONLY if it is necessary not only to set and get each variable in your object .

+3
source share

If you use identifiers that are valid Java variable names (this means that they consist only of az, AZ, 0-9 and underscores), you will have no problem. The actual namespace is probably larger, but this works for me.

documentation

+2
source share

I just turn on and say this:

You cannot use keywords, but managing Android resources is not so simple ... for example, you cannot have different folders for drawings, they need to go to the drawable-xxxx folder ...

So, try to come up with reasonable prefixes for your drawings and selectors.

Android accepts all valid Java variable names, so I really don't see where this question comes from.

+1
source share

All Articles