Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 479
Robin Avatar asked Jun 14 '11 10:06

Robin


People also ask

How do I add a line break in Android?

Add Line Breaks to a TextView Just add a \n to your text. This can be done directly in your layout file, or in a string resource and will cleanly break the text in your TextView to the next line.

Does HTML support Android?

text. HTML that processes HTML strings into displayable styled text and then we can set the text in our TextView. We can also use WebView for displaying HTML content. Currently Android does not support all the HTML tags but it supports all major tags.

How do I add a new line to a string in XML?

Add \t for tab and \n for new line.


1 Answers

wrong end tag:

b.setText(Html.fromHtml("<b>" + st + "</b>" + "<br/>" + cursor.getString(1)));
like image 153
vieux Avatar answered Sep 19 '22 20:09

vieux