Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Alert dialog Title bar

Tags:

I am following this code to create custom dialog but i am not getting how to remove dialog title bar ?

  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;        .......  } 

I know to remove title area of the Alert Dialog, we have to use requestWindowFeature(Window.FEATURE_NO_TITLE);

But don't know where i have to place above line ?

like image 373
Sun Avatar asked Feb 23 '15 06:02

Sun


People also ask

How do I turn off alerts in dialog?

AlertDialog generally consists of the main title, the message, and two buttons, technically termed as a positive button and a negative button. Both positive and negative buttons can be programmed to perform various actions. By default, the negative button lets close the AlertDialog without any additional lines of code.

What is alert dialog in Android?

Android AlertDialog can be used to display the dialog message with OK and Cancel buttons. It can be used to interrupt and ask the user about his/her choice to continue or discontinue. Android AlertDialog is composed of three regions: title, content area and action buttons.

What is the difference between an alert and an alert dialog?

AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .


1 Answers

If you don't want title bar in alert dialog then just remove below line from code.

dialogbuilder.setTitle("Login"); 

If still not working then add below line.

dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE); 
like image 152
Niranj Patel Avatar answered Sep 18 '22 09:09

Niranj Patel