安卓string.xml阅读HTML标签的问题标签、问题、string、xml

2023-09-12 22:10:39 作者:只能谈情不能说爱

在Android项目的的strings.xml文件,我有以下的HTML文本

In Android project's strings.xml file i have following html text

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="myHeadStr"><b><u>bold, underline </u></b></string>
...

</resources>

当我阅读到这一点的getString(R.string.myHeadStr)它给了只有文字粗体,下划线很难忘记的HTML标签和......

When i read this into getString(R.string.myHeadStr) it gives only text "bold, underline" it forgets the html tags and ....

如何阅读完整的字符串与string.xml html标签

how to read complete string with html tags from string.xml

推荐答案

使用XML CDATA

Use XML CDATA

<string name="demoStr"><Data><![CDATA[ <b>ABC</b> ]]> </Data></string>

的getString()将获得&LT; B&GT; ABC&LT; / B&gt;中