0

How to get rid of annoying title in dialog in android ?

this like i read the dialog:

data myDialog = new data(context);
myDialog.show();

this my dialog

public class data extends Dialog {
    public data(Context context) {
        super(context);
    }
    TextView txtName;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.data);
        setTitle("annoying  title");
        Button btnClose;
        Button btnexit;

        txtName = (TextView)findViewById(R.id.txtName);
        txtName.setText(MyParam.Fname_Lname);
        //txtName.setText(MyParam.zPhone);


        btnClose = (Button) findViewById(R.id.btnDiel);
        btnClose.setOnClickListener(new Close());

        btnexit = (Button) findViewById(R.id.btnSMS);
        btnexit.setOnClickListener(new exit());
    }

    private class Close implements android.view.View.OnClickListener {
        public void onClick(View v) {
            data.this.dismiss();
        }
    }

    private class exit implements android.view.View.OnClickListener {
        public void onClick(View v) {
             data.this.dismiss();
        }
    }

i try to remove this line setTitle("annoying title");

i try this

myDialog.getWindow();
myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

but if i do this i see my dialog as Vertical line

Aleks G
  • 56,435
  • 29
  • 168
  • 265
Gold
  • 60,526
  • 100
  • 215
  • 315

2 Answers2

3

Try this dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); before dialog.setContentView(R.layout.mydialog);

You just define theme android:theme="@android:style/Theme.Light.NoTitleBar" in activity where you don't want to display title bar.

For more info Custom Dialog without title and border.

Android Dialog: Removing title bar

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
0

i don't know where you declared the type data, but where you call the Dialog constructor do it like that:

new Dialog(getContext(),android.R.style.Theme_Translucent_NoTitleBar);
Rotem
  • 1,472
  • 2
  • 11
  • 18