Rajendran
Rajendran

Reputation: 1

how to give line break in message in alert dialog box?

Using the following code I am unable to break the line to 2.

builder.setMessage(Html.fromHtml("<b>"+"World"+"</b>+\n+second line"))

Result I get like: World+ +second line

Upvotes: 0

Views: 3245

Answers (3)

Satyen Udeshi
Satyen Udeshi

Reputation: 3243

If you are using Html.fromHtml() then use <br/> where you want a line break for e.g:

builder.setMessage(Html.fromHtml("<b>"+"World"+"</b><br/>"+"second line"))

and if not Html and just String you can use \n where you want a line break.

Upvotes: 2

KishuDroid
KishuDroid

Reputation: 5451

You can easily do it by writing below code :

builder.setMessage("First line \n"+"second line"));

Upvotes: 0

J.Chao
J.Chao

Reputation: 26

en..u can use '\n',like that

            ProgressDialog progressDialog=new ProgressDialog(MainActivity.this);
            progressDialog.setMessage("Str1"+"\n"+"Str2"+"\n"+"Str3");
            progressDialog.show();

you can try it.

Upvotes: 0

Related Questions