Domanda

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?

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top