tags:

views:

1162

answers:

3
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.

+1  A: 

I think your question has already been answered in this thread

http://stackoverflow.com/questions/820398/android-change-custom-title-view-at-run-time

please do some searching and accept answers before asking questions.

pvsnp
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
Why have you accepted this answer then?
Janusz
A: 

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.

mbaird
A: 

use two lines of code to remove dialoge title

Dialog dialog = new Dialog(this); dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);

alok tiwari