Android Custom Dialog Class Title Problems

Posted by y ramesh rao on Stack Overflow See other posts from Stack Overflow or by y ramesh rao
Published on 2009-12-10T13:04:47Z Indexed on 2010/04/15 9:33 UTC
Read the original article Hit count: 318

Filed under:
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.

© Stack Overflow or respective owner

Related posts about android