开发者

How do i add a new line in html format in android?

开发者 https://www.devze.com 2023-03-13 01:36 出处:网络
I have to add text to a开发者_StackOverflow button bolding the first line and unbolding the second but i cant figure out which new line character it is.

I have to add text to a开发者_StackOverflow 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.

Thanks in advance


wrong end tag:

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号