[英]Inserting HTML formatted (not a resource) string in android TextView
[英]android - HTML in String resource
我試圖通過使用WebView
來證明文本的合理性,並在一些示例中使用HTML格式化String資源:
<string name="dTxt">
<html>
<head></head>
<bodystyle text-align:justify=""><body> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc pellentesque, urna nec hendrerit pellentesque, risus massa </body>
</bodystyle>
</html>
</string>
ADT拒絕解析Strings文檔,但有以下錯誤:
W/ResourceType( 2612): Bad XML block: header size 296 or total size 6144712 is larger than data size 0
這有什么不對?
njzk2是對的,<和>被禁止直接用作字符串。 但是,您可以將CD包裝在CDATA中:
<string name="dTxt">
<![CDATA[
<html>
<head></head>
<bodystyle text-align:justify="">
<body> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc pellentesque, urna nec hendrerit pellentesque, risus massa
</body>
</bodystyle>
</html>
]]>
</string>
在java代碼中嘗試使用Html.fromHtml(source)
這些字符串Resource
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.