Special characters in a TextView

If nothing else helps, you can either:

  1. use a custom font (e.g. http://www.tutorialspoint.com/android/android_custom_fonts.htm or Add custom font for complete android application ) or

  2. add an image: How to add image in a TextView text?


You can use an Unicode code: http://unicode-table.com/en/.

Such as:

txtCatname.setText("\u266b");

or alternatively use an iconic font, such as font awesome:
http://fortawesome.github.io/Font-Awesome/

Use this alternative (or any other iconic font you like), in case this character isn't supported (not all Unicode characters are supported).


That is common when the source file is encoded as ANSI. Converting the source file as UTF-8 (without BOM) will likely solve the issue.


Try this:

String str = "♫";
byte spbyte[] = str.getBytes("UTF-8"); 
str = new String( spbyte,"UTF-8");
txtCatname.setText(str);

If it doesn't work, try this:

String str = "♫";
txtCatname.setText(Html.fromHtml(str));