user2431262
user2431262

Reputation: 61

TextView not displaying Characters like "à è ì ò ù" in android

I have created a text view . there are various language character used. some character appearing at some place but not some place in text view. what may be reason.

Upvotes: 3

Views: 6183

Answers (3)

RWIL
RWIL

Reputation: 9169

I faced a similar issue when setting a textview with content from a .txt file loaded from my assets folder.

I tried a few things to mess with the encoding, but without result.

In the end the problem turned out not to be related to my Android code but to the text file that got loaded in. Apparently notepad could not handle the copy past html. When recreating the text-file with a custom editor (I used Sublime) the "?" on ë, ä, ù, ... got resolved to the correct character in my TextView.

Upvotes: 1

Mahesh
Mahesh

Reputation: 984

Try this I hope this will work.

myTextView.setText(Html.fromHtml("your_string"));

Upvotes: 3

Jibran Khan
Jibran Khan

Reputation: 3256

Unfortunately, you just can't do it that way from strings.xml AFAIK.

You're left doing one of two things.

Adding the Unicode character within java to the String in the XML file:

String str = "\u00A9" + getContext().getString(R.string.your_string);

Entering the text as HTML in java:

yourTextView.setText(Html.fromHtml("your chars");

Hope this is useful.

Reference Unicode characters not displayed in TextView.setText

Upvotes: 3

Related Questions