andorid中Html.fromHtml方法
16lz
2021-01-23
在android中,有一个容易遗忘的Html.fromhtml方法,意思是可以将比如文本
框中的字符串进行HTML格式化,支持的还是很多的,
但要注意的是要在string.xml中用去转义,比如:
Java代码
Text with markup for [b]bold[/b]
and [i]italic[/i] text.
There is also support for a
teletype-style font.
But no use for the code
tag!
]]>
上面就用到了大量的HTML标签了,JAVA代码中这样使用:
Java代码
TextView view = (TextView)findViewById(R.id.sampleText);
String formattedText = getString(R.string.htmlFormattedText);
Spanned result = Html.fromHtml(formattedText);
view.setText(result);
或者是这样写:
view.setText(Html.fromHtml("今天礼拜五"));
更多相关文章
- 〖Android〗OK6410a的Android HAL层代码编写笔记
- Android:如何从堆栈中还原ProGuard混淆后的代码
- android recovery 主系统代码分析
- Android 通过蓝牙控制小车源代码+视频
- Android SQLite详解及示例代码
- Android中打印代码的调用层次
- 【android】在Eclipse在联想引jar包源代码
- Android 2.3.3 安卓系统 源代码 在Eclipse查看方法
- Android proguard代码混淆