0

I added some strings to the strings.xml file, as the following:

<string name="29">Beaf Stake"</string>

I know that this is the way to retrieve strings from the ressources:

getResources().getString(R.string.29);

But the problem is that I don't find this string listed in R.string. I imported my Project's R as following:

import xxxx.xx.xxxx.xxx.R;

I tried restarting Eclipse with no luck, so what am I doing wrong?

Ziad Akiki
  • 2,601
  • 2
  • 26
  • 41

2 Answers2

3

Having a numeric variable name is wrong . It won't allow such thing and instead throw an error.

I request you to change your string name. May be follow the recommendations Are there conventions on how to name resources?

Community
  • 1
  • 1
moDev
  • 5,248
  • 4
  • 33
  • 63
  • 1
    Yes you were right! I changed the string name to something other than numeric and I works. I would accept the answer as soon as possible! – Ziad Akiki Feb 19 '13 at 18:48
0

Your resource name can't start with a number and you have to escape quotes either with an esacape character or enclose the whole sting.

<string name="29">Beaf Stake"</string>

should be

<string name="29">"Beaf Stake"</string>

or

<string name="29">Beaf Stake/"</string>

Link

codeMagic
  • 44,549
  • 13
  • 77
  • 93