Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Html and Set text to Textview

Tags:

html

android

I am trying to convert a html String and set it to a TextView but I couldn't do it exactly.

Here is my String, "Hello, %1$s! You have <b>%2$d new messages</b>"

I am using textview.setText(Html.fromHtml(myString)); which produces me an output with Html Tags instead of plain text. Can anyone help me with this?

Any help is much appreciated. Thanks

like image 472
Andro Selva Avatar asked Nov 17 '11 06:11

Andro Selva


3 Answers

Refer to this question.

try:

textView.setText(Html.fromHtml(myString), TextView.BufferType.SPANNABLE);
like image 50
Paul Burke Avatar answered Nov 01 '22 15:11

Paul Burke


This may be helpful to you:

Spanned marked_up = Html.fromHtml(myString);
textview.setText(marked_up.toString(),BufferType.SPANNABLE);
like image 39
Paresh Mayani Avatar answered Nov 01 '22 14:11

Paresh Mayani


Try use this version of setText and use SPANNABLE buffer type

like image 45
HighFlyer Avatar answered Nov 01 '22 15:11

HighFlyer