原文: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
. Here is an example:
source code]]>
<string name="html"><![CDATA[<p>Text<p>]]></string>
Then you can display this html in TextView using:
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:
myTextView.setMovementMethod(LinkMovementMethod.getInstance());
时间: 2024-11-05 20:47:19