如何删除警报对话框标题栏

我下面这个代码来创build自定义对话框,但我没有得到如何删除对话框标题栏?

AlertDialog alertDialog; @Override protected Dialog onCreateDialog(int id) { AlertDialog dialogDetails = null; switch (id) { case DIALOG_LOGIN: LayoutInflater inflater = LayoutInflater.from(this); View dialogview = inflater.inflate(R.layout.dialog_layout, null); AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this); dialogbuilder.setTitle("Login"); dialogbuilder.setView(dialogview); dialogDetails = dialogbuilder.create(); break; } return dialogDetails; } @Override protected void onPrepareDialog(int id, Dialog dialog) { switch (id) { case DIALOG_LOGIN: alertDialog = (AlertDialog) dialog; ....... } 

我知道要删除Alert对话框的标题区域,我们必须使用requestWindowFeature(Window.FEATURE_NO_TITLE);

但不知道我要放在哪里?

Solutions Collecting From Web of "如何删除警报对话框标题栏"

如果你不想在标题栏提醒对话框,然后从代码中删除下面的行。

 dialogbuilder.setTitle("Login"); 

如果仍然不工作,然后添加下面的行。

 dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE); 

使用dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);dialog.setContentView(R.layout.logindialog);之前dialog.setContentView(R.layout.logindialog); 通过这样做,您将能够隐藏Dialog的标题。

使用dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

首先删除这一行:

 dialogbuilder.setTitle("Login"); 

然后添加这个:

 dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE); 

尝试这个::

 AlertDialog.Builder builder; AlertDialog alertDialog; Context mContext = getApplicationContext(); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.custom_dialog, (ViewGroup) findViewById(R.id.layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setText("Hello, this is a custom dialog!"); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(R.drawable.android); builder = new AlertDialog.Builder(mContext); builder.setView(layout); alertDialog = builder.create(); 

请参阅这里

只是删除

 dialogbuilder.setTitle("Login"); 

AlertDialog Builder找不到.requestWindowFeature

如果使用Builder构buildAlert对话框时不想使用标题,请使用new AlertDialog.Builder(getContext(), android.R.style.Theme_Material_Light_Dialog_NoActionBar_MinWidth);

用这个

 AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this); dialogbuilder .requestWindowFeature(Window.FEATURE_NO_TITLE); dialogbuilder.setView(dialogview); dialogDetails = dialogbuilder.create();