android.text.Html(1)

来源:互联网 发布:夺命呼软件下载 编辑:程序博客网 时间:2024/05/22 06:59

TextView显示带有格式的文字


TextView tv=(TextView)findViewById(R.id.t1);  

String html="<html><head><title>HTML测试</title></head><body><p><strong>强调</strong></p><p><em>斜体</em></p>"  
+"<p><a href=\"http://www.dreamdu.com/xhtml/\">超链接</a>this is a test</p><p><font color=\"#aabb00\">颜色1"  
+"</p><p><font color=\"#00bbaa\">颜色2</p></body></html>";  
        tv.setMovementMethod(ScrollingMovementMethod.getInstance());//滚动  
        tv.setText(Html.fromHtml(html));   
0 0