Search code examples
javaandroidspecial-charactershtmlspecialchars

How to use these special characters in Android?


I am developing an Android native app where i need to use some special characters. After a lot of search in google i found the following How to put some special math symbols in TextView, EditView or other Android UI element. I tried the same code but when executing it in my text view it is not displaying as special characters as per the diagram give in that url. Getting output as same text which we are passing.. Code i am following is..

code:

    String htmlStringWithMathSymbols = "−   +   ± ×   ÷   %   ‰   =   ≠";

    txtv.setText(Html.fromHtml(htmlStringWithMathSymbols));

As per my code when i executed it i am not getting output like special math symbols, getting output as same text like "− + ±...."

So, how can we get special math symbols as per the following code from the URL mentioned above....

Thanks in advance.........


Solution

  • What you are doing wrong is writing &#xxxx;. With that you tell the HTML parser, that you want to have the sign & (what is the & sign itself) followed by the text behind.

    If you want to have it written as mathematical symbols write &#xxx; instead, than it will work.