Android中html.fromhtml的使用方法
更新時間:2017年01月24日 09:51:18 投稿:lqh
這篇文章主要介紹了Android中html.fromhtml的使用方法的相關(guān)資料,需要的朋友可以參考下
Android中html.fromhtml
在android中,有一個容易遺忘的Html.fromhtml方法,意思是可以將比如文本 框中的字符串進行HTML格式化,支持的還是很多的,
但要注意的是要在string.xml中用<!--cdata-->去轉(zhuǎn)義,比如:
<string name="htmlFormattedText"> <![CDATA[ Text with markup for [b]bold[/b] and [i]italic[/i] text. There is also support for a <tt>teletype-style</tt> font. But no use for the <code>code</code> tag! ]]></string>
上面就用到了大量的HTML標簽了,JAVA代碼中這樣使用:
TextView view = (TextView)findViewById(R.id.sampleText); String formattedText = getString(R.string.htmlFormattedText); Spanned result = Html.fromHtml(formattedText); view.setText(result);
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
您可能感興趣的文章:
相關(guān)文章
Android判斷網(wǎng)絡(luò)狀態(tài)的代碼
這篇文章主要為大家詳細介紹了Android判斷網(wǎng)絡(luò)狀態(tài)的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10Android中pendingIntent與Intent的深入分析
這篇文章主要介紹了Android中pendingIntent的深入分析的相關(guān)資料,需要的朋友可以參考下2017-04-04Android神兵利器之Image Asset Studio的實現(xiàn)
這篇文章主要介紹了Android神兵利器之Image Asset Studio的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-06-06