android: show font icon as a sequence of number string

236 Views Asked by At

I want to put a Font-Awesome icon inside textview text. After I set the text, android shows me a string sequence instead of font-icon.

My code is:

String formatedSection = formatedSection + sections.get(i).getContent() +getResources().getString(R.string.icon_ref);

I define icon_ref in string.xml as below:

 <string name="icon_ref">&#xf075;</string>

I followed these instructions to add font-icon. What am I doing wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

If you did step 5 in that short guid your problem seem to forget that there is a diff between java and XML.

In XML you use XML escape (&...;), in Java you'll probably have to use Java escape (\u...). – Biffen May 20 at 10:10

Try to hard code the string into "\uf075" and it would work like a charm.