gbl
gbl

Reputation: 188

Integer as array name in string array

how can we strore integer as name in string array.i have to put numbers in my project.

here is my array.xml

<string-array name="1">
 <item>kN</item>
 <item>μg</item>
 <item>mg</item>
 <item>g</item>
 <item>kg</item>
</string-array>

thanks

Upvotes: 0

Views: 182

Answers (2)

Macrosoft-Dev
Macrosoft-Dev

Reputation: 2185

You can't use integer for name because later it will be converted into a variable name in R.java and a variable name in java can start only with $ (dollar sign), _ (underscore) or with any alphabet.

So instead of using <string-array name="1"> you can use <string-array name="_1"> or <string-array name="$1"> or <string-array name="a1">

Upvotes: 0

njzk2
njzk2

Reputation: 39397

The name must be a valid java identifier, because it is used in the generation of the R.java file.

See http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8

Typically, it cannot be (or start with) a number, and it cannot be true, false, null

Upvotes: 2

Related Questions