Andorid中Html.fromHtml方法

2014-11-24 10:36:41 · 作者: · 浏览: 0

但要注意的是要在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("今天礼拜五"));