Frage

Usually I use <![CDATA[..here's text]]> in my Resources Strings so when I do

Spanned sp=Html.fromHtml(getResources.getString(R.string.myString));
myTextView.setText(sp);

I get text with all the tags like ,
etc working as they should.

but now I build String during some metod like :

String result="<![CDATA[";
//some code
result+="<b>Chapter :"+chapterNumber+"</b><br /><br />"
//some other additions and in the end
result+="]]>";

Spanned sp = Html.fromHtml(result);
myTextView.setText(sp);

and I see all my tags on the screen instead of them being implemented, like : Chapter :1

...

I tried to use StringBuilder instead, but result is the same.

What should I do for the tags to word right in my case?

War es hilfreich?

Lösung

What should I do for the tags to word right in my case?

Get rid of the CDATA:

Spanned sp = Html.fromHtml("<b>Chapter :"+chapterNumber+"</b><br /><br />");
myTextView.setText(sp);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top