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

前端 未结 2 1601
悲哀的现实
悲哀的现实 2021-01-18 21:21

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(         


        
相关标签:
2条回答
  • 2021-01-18 22:01

    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 讨论(0)
  • 2021-01-18 22:19

    wrong end tag:

    b.setText(Html.fromHtml("<b>" + st + "</b>" + "<br/>" + cursor.getString(1)));
    
    0 讨论(0)
提交回复
热议问题