kgandroid kgandroid - 2 months ago 10
Android Question

TextView shows number instead of character

I want to print ŒHI 5¹ in my TextView. So I have simply written :

tv.setText("Welcome to " + R.string.app_name)

where R.string.app_name is
<string name="app_name"><b>ŒHI 5¹</b></string>

But the strange thing is textview is showing a number

The number is: 2131230755

I have no idea why this is happening.Please help.


use getString(R.string.app_name)



R.string.app_name is just a long number genereted to identify that resource. The result of string + long is just that long concatenated to that string. so you need to get the string corresponding to that identifier.

Actually every resource (layout, drawable, array, string) gets an identifier, these are put in the R file. layout identifiers are kept together in an inner class called layout, strings in string and so on.