0

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

6
  • developer.android.com/guide/topics/resources/… Commented Sep 9, 2013 at 11:50
  • what you want to store? Commented Sep 9, 2013 at 11:50
  • i want to store values from 1-20... so that according to index position we can extract value from another array. Commented Sep 9, 2013 at 11:52
  • when i save this..R. java save it as-> public static final int 1=0x7f040001;which shows error Commented Sep 9, 2013 at 11:54
  • @Raghunandan:i just want to store name as integer..list item will b string or symbols...so <integer-array> not worked in that case. Commented Sep 9, 2013 at 11:59

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.