开发者

displaying special characters in android app from sqlite database

I have a Periodic table of elements app for android that stores most of it's data in string arrays. I am now trying to use an sqlite database instead of the arrays but am having a small problem. If I type 'android:text="¹"' directly into a TextView it will display开发者_运维百科 a superscript 1(like this-> ¹), but if I store '¹' as text in a sqlite database and then use a cursor to populate that same TextView, instead of the superscript 1 being displayed I just see "¹" exactly as I typed it. How can I get the TextView to display special characters when being populated by a sqlite database? I have been struggling for a while and am stumped so any suggestions would be appreciated. Thanks!


Use the Java Unicode string notation for each special character when inserting them into your database.
For '¹', that would be: \u00b9.

Alternatively, to parse HTML tags and character entities like ¹ in a TextView, then you can probably wrap the String in a call to Html.fromHtml() before calling setText().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜