当前位置: 移动技术网 > IT编程>移动开发>Android > Android中html.fromhtml的使用方法

Android中html.fromhtml的使用方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

塘沽性息,张正九,联通号码查询

android中html.fromhtml

  在android中,有一个容易遗忘的html.fromhtml方法,意思是可以将比如文本 框中的字符串进行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); 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网