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));
Related
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());
I would like to remove the tag in my android which is coming from an web response. And I dont want to use Html.fromHtml in my setText(), as I would not like the text to appear in the next line. Can anyone please suggest me an idea?
You can use replaceAll() function
ex:
html.replaceAll("&","");//remove ampersands
You can use trim on the String returned by Html.fromHtml for avoiding newline before and after the text.
Source: How to remove newlines from beginning and end of a string (Java)?
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))
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("č");
try below code:-
txt.setText(Html.fromHtml("Č");//Capital C-hachek
txt.setText(Html.fromHtml("č");//Lowercase c-hachek
see link:-
http://webdesign.about.com/od/localization/l/blhtmlcodes-cz.htm
The response of a web service is the following :
<span style="color:#DDFFEE;">You have to pay you bil before <b>12 june 2012</b> for your informations.</span></br></br> You have already a large time.
I want to display this in a TextView.
I can't just simply put the response below in a String and applicate
myTextView.setText(Html.fromHtml(response));
It doesn't work because it can't be a String.
How can I do this dynamically please ?
You just need to put the String you get as a response, inside the fromHtml call, if it's not a String, maybe you just need to append .toString() to it, to get a String..
textView.setText(Html.fromHtml("<h2>This is HTML</h2>"));
You need to use Html.fromHtml() to use HTML in your XML Strings. Simply referencing a String with HTML in your layout XML will not work.
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));
here : Similar question