Android: html in strings.xml

墨蓝 2022-01-10 14:01 253阅读 0赞

原文:http://stackoverflow.com/questions/13425002/android-html-in-strings-xml

The best way to add html source code in strings.xml is to use <![CDATA[html source code]]>. Here is an example:

  1. <string name="html"><![CDATA[<p>Text<p>]]></string>

Then you can display this html in TextView using:

  1. myTextView.setText(Html.fromHtml(getString(R.string.html)));

If you have links in your html and you want them to be clickable, use this method:

  1. myTextView.setMovementMethod(LinkMovementMethod.getInstance());

发表评论

表情:
评论列表 (有 0 条评论,253人围观)

还没有评论,来说两句吧...

相关阅读