0

I am trying to use setText method for a TextView widget and fill it with a string resource as you can see in the code below:

TextView texthdlr = (TextView)findViewById(R.id.textView1);
texthdlr.setText(R.string.someText);

strings.xml:

<string name="someText">Some Text</string>

but instead of showing someText value, it shows random numbers. (e,g 2131361816)

samix73
  • 2,802
  • 4
  • 17
  • 29

2 Answers2

1

To get string from resources you need to use, getResources().getString()

So you need to use,

texthdlr.setText(getResources().getString(R.string.someText));
Lal
  • 14,726
  • 4
  • 45
  • 70
0

I believe R.string.someText is the ID of the String.

Try getString(R.string.someText)

jongusmoe
  • 676
  • 4
  • 16
  • but i used this R.string.someText earlier in my program in a Toast.makeText method and it worked just fine – samix73 Jun 11 '15 at 17:11