Android - Achieving line break in XML string with String.format()?



This is my xml string...



<string name="my_string">First line.\nSecond line: %1$s.\nThird line.</string>


...which I need to run through String.format without losing the line breaks.


How do I achieve that?


Here is my Java code...



String text = String.format(getString(R.string.my_string, "some text");
Spanned html = Html.fromHtml(text, this, null);
textView.setText(html);


In the xml file, I have tried using \n and <br /> and actual new lines, but none of them produce line breaks in the textView on the UI.


No comments:

Post a Comment