开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜