简体   繁体   English

java Android Spanned Html.fromHtml(stringWithCDATA)仍将标签显示为文本

[英]java Android Spanned Html.fromHtml(stringWithCDATA) still shows tags as text

Usually I use <![CDATA[..here's text]]> in my Resources Strings so when I do 通常我在资源字符串中使用<![CDATA[..here's text]]>

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:

 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 然后我在屏幕上看到了我所有的标签,而不是正在实施它们,例如:Chapter:1

... ...

I tried to use StringBuilder instead, but result is the same. 我尝试改用StringBuilder,但结果相同。

What should I do for the tags to word right in my case? 在我的情况下,如何正确处理标签?

What should I do for the tags to word right in my case? 在我的情况下,如何正确处理标签?

Get rid of the CDATA : 摆脱CDATA

Spanned sp = Html.fromHtml("<b>Chapter :"+chapterNumber+"</b><br /><br />");
myTextView.setText(sp);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM