Samantha Withanage
Samantha Withanage

Reputation: 3851

How to Edit Android dialog heading

Can I enter two text rows as the Android dialog heading. If so, how can I do that? I tried as,

AlertDialog.Builder builder=new AlertDialog.Builder(Login.this,android.R.style.Theme_Holo_Dialog).setTitle(Heading)

and set the title using new line character as below.

Heading="raw 1 \n raw 2";

but it's not working and just show the "\n" in the heading. How can I do this?

Upvotes: 3

Views: 103

Answers (3)

Deepak Jangir
Deepak Jangir

Reputation: 590

Use string to declare : <string name="text">row1\nrow2</string>

builder.setTitle(getString(R.string.text));

Upvotes: 0

Anu
Anu

Reputation: 7177

Use Html.fromHtml() method to show html content on TextView

EX:

String Heading="raw 1 \n raw 2";

textView.setText(Html.fromHtml(Heading));

dialogBuilder.setCustomTitle(textView);

Upvotes: 0

Digvesh Patel
Digvesh Patel

Reputation: 6533

builder.setTitle("raw 1 \n raw 2");

And onother Solution i s

TextView textView = new TextView(context);

textView.setText("raw 1 \n raw "2);

dialogBuilder.setCustomTitle(textView);

Upvotes: 2

Related Questions