Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying multiple lines of text in an Alert Dialog

I need to display multiple lines of messages, rather than just one paragraph, in an alert dialogue.

new AlertDialog.Builder(this)
.setTitle("Place")
.setMessage("Go there" +
        "Go here")
.setNeutralButton("Go Back", null)
.show();

Is there a way to start at new lines? Just like hitting enter after a sentence in Microsoft Word?

like image 582
Captn Buzz Avatar asked Dec 14 '11 20:12

Captn Buzz


2 Answers

No guarantees on this, but usually to do multiple lines you do something like:

.setMessage("Go there\nGo here");

The "\n" is an escape character that means "New Line" I don't know about your specific case, but you can use it in just about everything AFAIK.

like image 158
Cody S Avatar answered Oct 08 '22 07:10

Cody S


Use the "\n" tag in your strings:

new AlertDialog.Builder(this)
    .setTitle("Place")
    .setMessage("Go there" + "\n" +
            "Go here")
    .setNeutralButton("Go Back", null)
    .show();
like image 20
Adam Toth Avatar answered Oct 08 '22 06:10

Adam Toth