2
public class MessageDisplayDialog extends Dialog implements OnClickListener

{

    public MessageDisplayDialog(Context context, String title, String message)
    {
        super(context);
        setTitle(title);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.color.default_text_color);
        Log.v(getClass().getSimpleName(), "MessageDisplayDialog");
        LinearLayout objLinearLayout = new LinearLayout(context);
        LinearLayout objButtonLayout = new LinearLayout(context);

        TextView objMesaageView = new TextView(context);
        objMesaageView.setText(message);
        objMesaageView.setTextColor(Color.WHITE);
        objMesaageView.setGravity(Gravity.CENTER_HORIZONTAL);
        objMesaageView.setPadding(0, 0, 0, 10);

        Button okButton = new Button(context);
        okButton.setText(" OK ");
        okButton.setOnClickListener(this);
        okButton.setWidth(100);
        objButtonLayout.addView(okButton);
        objButtonLayout.setGravity(Gravity.CENTER_HORIZONTAL);
        objButtonLayout.setPadding(0, 5, 0, 0);
        objButtonLayout.setBackgroundColor(Color.LTGRAY);

        objLinearLayout.setOrientation(LinearLayout.VERTICAL);
        objLinearLayout.addView(objMesaageView);
        objLinearLayout.addView(objButtonLayout);

        setContentView(objLinearLayout);
        //LayoutParams param = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        //this.addContentView(objLinearLayout, param);
    }

    public void onClick(View v)
    {
        this.dismiss();
    }
}

But the Dialog is not showing bar below the Title, how to crack it.

Janusz
  • 187,060
  • 113
  • 301
  • 369
y ramesh rao
  • 2,954
  • 4
  • 25
  • 39

4 Answers4

3

I think your question has already been answered in this thread

Android - change custom title view at run time

please do some searching and accept answers before asking questions.

Community
  • 1
  • 1
prasanna
  • 1,887
  • 3
  • 20
  • 26
  • 3
    Mate I don't require to change titles.... My Dialog is not Displaying Separator under Title... I require Solution to my that query... Please Read the Question Before jumping to conclusions of your randomness – y ramesh rao Dec 10 '09 at 13:29
2

I think the horizontal border between the title and the message in the built in dialogs is part of AlertDialog, not the base Dialog class, although I could be totally wrong about that. Regardless, whenever I attempt to do something similar to what you are doing, that horizontal line disappears and I've never been able to get it back.

I ended up just writing my own dialog layout XML file and creating my own horizontal line using a <shape> drawable. It's actually fairly painless to create your own completely custom Dialog layouts like this, and gives you more control over the look of your dialogs.

Mark B
  • 183,023
  • 24
  • 297
  • 295
2

This is old I know, but FYI the solution of drawing your own line on a custom dialog is not compatible with ICS.

It will display both your line and the line that ICS is now including by default. So you'd get two lines on the screen.

Stephan Tual
  • 2,617
  • 3
  • 27
  • 49
1

use two lines of code to remove dialoge title

Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
Lucifer
  • 29,392
  • 25
  • 90
  • 143
alok tiwari
  • 637
  • 5
  • 2