gurehbgui
gurehbgui

Reputation: 14694

how to display special chars in a android button/textview?

I need to display s.th. like 10ˣ on a android button or textview.

So I added it to the strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="a10x">10ˣ</string>
</resources>

the problem is, then I start the app I just see the 10 and the x is missing.

How to fix this?

Upvotes: 0

Views: 1273

Answers (2)

SweetWisher ツ
SweetWisher ツ

Reputation: 7306

Try this :

((TextView)findViewById(R.id.text)).setText(Html.fromHtml("10<sup>x</sup>"));

Upvotes: 3

Gunaseelan
Gunaseelan

Reputation: 15535

<string name="10x">10ˣ</string> 

Please change this variable name to something like start with alphabets. Because this will produce error in R.java file. public static final int 10*=0x7f04009a; see here, Your variable will create a variable in R.java like this. This is wrong in java naming conversion. I hope this is only problem. Otherwise use some codes like &#160, this is for single space.

I hope this will help you.

Upvotes: 1

Related Questions