问题
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.
Thanks in advance
回答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.
回答2:
wrong end tag:
b.setText(Html.fromHtml("<b>" + st + "</b>" + "<br/>" + cursor.getString(1)));
来源:https://stackoverflow.com/questions/6342042/how-do-i-add-a-new-line-in-html-format-in-android