Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I preserve line breaks from EditText?

Tags:

android

The following ignore new lines when I display them

private void post() {
        String subject = "";
        String message = "";
        subject = etSubject.getText().toString();
        message = etMessage.getText().toString();

edit: My edittext is already set to multiline however when I write multilined text in it it's returned as a single line with the cover above

edit2: i am getting the text from an editText and displaying it on a textview

like image 936
code511788465541441 Avatar asked Jul 01 '12 17:07

code511788465541441


1 Answers

Solved it by using replaceAll("\\n", "<br />")

message = etMessage.getText().toString().replaceAll("\\n", "<br />")
like image 135
code511788465541441 Avatar answered Oct 06 '22 18:10

code511788465541441