Markus Schmitz
Markus Schmitz

Reputation: 117

converting HTML to String without TextView

I am having Problems filling my TextView. I have an HTML String that needs to be converted from HTML to String and the replace some characters. Problem is: I can convert it directly with: TextView.setText(Html.fromHtml(sampleText);

But I need to alter the converted sampleText before giving it to the TextView.

E.g.:

String sampleText = "<b>Some Text</b>"
newSampleText = Html.fromHtml(sampleText);
newSampleText.replace(char1, char2);
TextView.setText(newSampletext);

Does anyone know how to convert the HTML saved inside the String?

Upvotes: 0

Views: 9165

Answers (2)

Yazazzello
Yazazzello

Reputation: 6233

if you don't need formatting, use Html.fromHtml(sampleText).toString()

otherwise, you need to extract text from html with jsoup to find and change text like here

Upvotes: 4

Ivin Raj
Ivin Raj

Reputation: 3429

please try this one:

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.

DEMO

Try use This version of setText and use SPANNABLE buffer type

DEMO1

Upvotes: 0

Related Questions