andorid中的html.fromhtml方法
16lz
2021-01-26
在android中,有一个容易遗忘的Html.fromhtml方法,意思是可以将比如文本
框中的字符串进行HTML格式化,支持的还是很多的,
但要注意的是要在string.xml中用<!--cdata-->去转义,比如:
上面就用到了大量的HTML标签了,JAVA代码中这样使用:
框中的字符串进行HTML格式化,支持的还是很多的,
但要注意的是要在string.xml中用<!--cdata-->去转义,比如:
<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);
更多相关文章
- intent-filter的data属性详述
- Android(安卓)中短信数据库的简单操作
- Android(安卓)Html.fromhtml
- android的http工具类
- 待研究
- android中json解析的两个工具:Gson和Jackson的使用小demo
- Android获取手机屏幕宽高、状态栏高度以及字符串宽高信息的方法
- Android字符串处理类-TextUtils类
- Android(安卓)开发必备AS插件,写下来,方便自己用