閱讀805 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Android: html in strings.xml

原文:https://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:

<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());

最後更新:2017-04-03 16:48:33

  上一篇:go 【OpenHW參賽手記】AXI-Stream接口開發詳細流程
  下一篇:go Android 開機圖片/文字/動畫 修改