TextView is not showing č character - android

I am working on an android app in which I am getting data in multiple languages everything is working fine but i am facing a small problem some characters are not visible in textview and edittext
The main problem with this č character.
I tried some stuffs like:
Html.fromHtml("č");
I also tried unicode character format but still not working.
Thanks!

Try using the HTML equivalent:
Html.fromHtml("&#269");

try below code:-
txt.setText(Html.fromHtml("&#268");//Capital C-hachek
txt.setText(Html.fromHtml("&#269");//Lowercase c-hachek
see link:-
http://webdesign.about.com/od/localization/l/blhtmlcodes-cz.htm

Related

Android Html.fromHtml function auto converts undesired text into hyperlinks

Android Html.fromHtml function auto converts undesired text into hyperlinks.
Here is my code:
String htmlContent= "corners of nail.It has to";
textViewContent.setTextHtml.fromHtml(htmlContent));
textViewContent.setText(comment.getContent());
In above code Html.fromHtml treats "nails.It" as a link and converts it into hyperlink.
Here is the result of converted string.
One of the solution which I could think is, put space after fullstop.
Is there any good solution?
You can try something like this.
textViewContent.setText( Html.fromHtml("YOUR DESIRED TEXT"));
textViewContent. setMovementMethod(LinkMovementMethod.getInstance());
Hope it helps.
Provide space between dot and second statement
String htmlContent= "corners of nail. It has to";
textViewContent.setTextHtml.fromHtml(htmlContent));
textViewContent.setText(comment.getContent());

u\2022 not displaying in textview that retrieves from json

I had found an answer that we can use bullets in textview by adding u\2022 with the text.
Ref : https://stackoverflow.com/a/3429643/4919237
When i added this code through XML it displays fine in TextView
and When i try to display bullet through json it doesnt display bullet ,instead it displays the text u\2022 itself.
my receiving Json format is
{"description":"\\u2022first one\\n\\u2022second one edited\\n"}
please help me to reslove my problem.
At First , You can check Html.fromHtml & remove one \ .
Html.formHtml method takes an Html.TagHandler and an Html.ImageGetter
as arguments as well as the text to parse.
YourTextViewObj.setText(Html.fromHtml("Your String"));
FYI
Currently android seems support the following HTML tags to be rendered on TextView.
You can set text using Html.fromHtml like
textview.setText(Html.fromHtml(your description));

Android Studio messes up brazilian-portuguese characters

My project isn't showing any portuguese characters. When I try to type a word like "Não" it returns Não".
The funny thing is that when I get the string from res/string.xml, it shows the word correctly.
Any idea why?
Things I've tried so far and did not work out:
File -> Settings -> Editor -> File Encondings, I've changed everything to UTF-8 and others, rebuild/cleaned the project, and it kept the same.
EDIT:
I can upload a video on youtube showing it, if it helps with the solution!
There goes an image of what is happening:
My file build.gradle had this line:
compileOptions.encoding = 'ISO-8859-1'
Because of that I wasn't able to change anything. Now it's fixed. :)
This is really hard to explain why is it is, I had same with russian characters, but only on SOME devices. I've just checked to do same as you on Genymotion and it displays correctly... From my investigation it is up to each device how to display given characters, but also I assume it could happen because Android knows how to works with Resources, but doesn't with Strings from code. When you create folders for different languages you don't say that default must be English. So system gonna detect and display. I'm not sure 100%, but this is what I understood from doc.
Anyways, for using String object in TextView from code and displaying foreign (from English) languages we have just 2 options:
1) Add .ttf file for particular text/Unicode
2) html format
Example for first option:
String s="(Mouy t'ngai) (១ ថ្ងៃ)";
TextView text_view1 = null;
text_view1 = (TextView) findViewById(R.id.textView2);
Typeface font= Typeface.createFromAsset(getAssets(), "khmerOS.ttf");
text_view1.setTypeface(font);
text_view1.setText(s);
// you can use different type of .ttf like
TAU_BHON.TTF
molten.ttf
arialuni.ttf
Example of Second option:
tv.setText(Html.fromHtml("\\u27A1");
Source.
P.S. If I missed something, please fill free to notice that.

How to set unicode in textview to show emoji in android?

I am getting some Unicode string(emoji icons) from server in json string format.
My problem is strange and I am trying for last two days to resolve this issue. When I parse json and store all the Unicode string in an ArrayList<String> and try to set the text on TextView by getting value from the same ArrayList then it shows Unicode characters as :
Ghcghchgc\ud83d\ude03\ud83d\ude03fyju\ud83d\ude0c6\u20e3
and when the same string I set on textview by passing static value as :
textview.settext("Ghcghchgc\ud83d\ude03\ud83d\ude03fyju\ud83d\ude0c6\u20e3")
then the textview is showing perfect emojis.
I am stuck at this point. Can anybody please help me to resolve this issue or tell me if I am doing something wrong.
This sounds like you want to unescape your string that you've got from JSON. If you don't mind adding a library, Apache Commons has a String.unescapeJava function which does what you need. If you don't want to add that library, see this answer.
This is what has worked for me ( Kotlin version ):
textView.text = String(Character.toChars(0x1F389))

how to use HTML tags to format text in an EditText in android

my code looks like this
txtData=(EditText)findViewById(R.id.textbox);
txtData.setText(Html.fromHtml("<b><html></b>"));
as you can see i am trying to make HTML code appear in an EditText box. I am trying to use HTML tags using the Html.fromHtml() method to format the HTML code that appears in the box.
i need to find a way to escape the '<' and '>' tags around the word html from being processed by the fromHtml method. any suggestions on how to do this ?
try this:
txtData=(EditText)findViewById(R.id.textbox);
txtData.setText(Html.fromHtml("<b><html></b>"));
or
txtData=(EditText)findViewById(R.id.textbox);
txtData.setText(Html.fromHtml("<b><html></b>"));
Try this:
txtData.setText(Html.fromHtml("<b><html><b>"));
You should use
<
and
>
as in this example
txtData.setText(Html.fromHtml("<b><html></b>"));

Categories

Resources