stramin
stramin

Reputation: 2400

Url stored in string resource turns into number in Andrioid

I stored an url on the strings.xml file to show it in my app, it is something like this:

<string name="url_stat">https://my.websyte.net/url_stramin/api/v1/</string>

When I want to use it in java I call it this way:

textView.setText(R.string.url_stat+"key/");
Log.i("KEY",R.string.url_stat+"key/");

But what I get is this text:

2131623976key/

for some reason this string turns into a number, why? how to avoid it?

Upvotes: 0

Views: 54

Answers (2)

Boardy
Boardy

Reputation: 36237

That number is the numerical identifier (the resource value) you should do the following

textview.setText(getString(R.string.url_stat) + "key/"); 

Upvotes: 5

Samuel Lu&#237;s
Samuel Lu&#237;s

Reputation: 171

Have you tried to add the CDATA Tag in your xml? Something like this:

<string name="url_stat"><![CDATA[https://my.websyte.net/url_stramin/api/v1/]]></string>

I'm not sure if it works, I haven't tested

Upvotes: 0

Related Questions