The difference between AlertDialog.builder obj.create () vs obj.show () vs obj.create (). Show ()

Is there a difference between the .create () and .show () methods of the Builder AlertDialog class? For example, when we create a warning dialog using:

AlertDialog.Builder builder = new 
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("");
builder.setPositiveButton(....)
builder.setNegativeButton(....)

What is recommended to use pratice and why?

builder.create() //I have seen this creates and displays the dialog

OR

builder.show() //this also displays the dialog

OR

builder.create().show() //well same thing

I read the documentation. But he could not make any sense from him. Any ideas?

+7
source share
2 answers

obj.create()-For create Dialog

obj.show()-For show Dialog <- without it you cannot show a dialogue if you created.

and

obj.create().show()-create and show Dialog i mean both same as above two in one statement.

+5
source

builder.show () returns an AlertDialog object and displays it immediately. As stated in the documentation, the call to this method is functionally identical:

AlertDialog dialog = builder.create();
dialog.show();

builder.create() AlertDialog , , . , AlertDialog , dialog.show().

0

All Articles