android TextView setText property shows random numbers

174 Views Asked by At

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)

2

There are 2 best solutions below

0
On BEST ANSWER

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

So you need to use,

texthdlr.setText(getResources().getString(R.string.someText));
1
On

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

Try getString(R.string.someText)