Как удалить диалоговое окно оповещений

Я следую этому > коду для создания настраиваемого диалога, но я не понимаю, как удалить панель заголовков диалогового окна?

  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);

Но не знаете, где я должен разместить выше строки?

Ответы

Ответ 1

Если вам не нужна панель заголовка в диалоговом окне предупреждения, просто удалите строку ниже кода.

dialogbuilder.setTitle("Login");

Если все еще не работает, добавьте строку ниже.

dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE);

Ответ 2

Используйте dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); до dialog.setContentView(R.layout.logindialog);, тем самым вы сможете скрыть заголовок Dialog.

Ответ 3

Используйте dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

Ответ 4

Сначала удалите эту строку:

dialogbuilder.setTitle("Login");

Затем добавьте следующее:

dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE);

Ответ 5

просто удалите

dialogbuilder.setTitle("Login");

Ответ 6

Попробуйте следующее:

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();

См. здесь

Ответ 7

Я не смог найти .requestWindowFeature с AlertDialog Builder.

Если вы не хотите иметь заголовок при построении диалогового окна оповещений с помощью Builder, используйте new AlertDialog.Builder(getContext(), android.R.style.Theme_Material_Light_Dialog_NoActionBar_MinWidth);

Ответ 8

Используйте этот

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