如何添加HTML格式的新生产线在android系统? [英] How do i add a new line in html format in android?

查看:133
本文介绍了如何添加HTML格式的新生产线在android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要添加文本到一个按钮加粗的第一行和unbolding第二,但我不能弄清楚它是新行字符。

I have to add text to a button bolding the first line and unbolding the second but i cant figure out which new line character it is.

b.setText(Html.fromHtml("<b>" + st + "<\b>" + "\n" + cursor.getString(1)));

香港专业教育学院还试图

ive also tried

b.setText(Html.fromHtml("<b>" + st + "<\b>" + "<br/>" + cursor.getString(1)));

第二个工程,但两条线路都加粗了。

the second one works but both lines are bolded.

在此先感谢

推荐答案

而不是使用HTML格式文本(这是比较慢的),你可以使用它跨度让你更严格的控制,以及更有效。我写了一篇关于使用跨度可以帮助你上手博客文章

Rather than using HTML to format your text (which is relatively slow) you could use Spans which give you much tighter control, and are more efficient. I wrote a blog post about the use of spans which may help you to get started.

这篇关于如何添加HTML格式的新生产线在android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆