user2401745 user2401745 - 7 months ago 85
Android Question

Android Dialog Box without buttons

Can i create a dialog box without negative or positive buttons. That destroys it self after specific action?

AlertDialog.Builder dialog_detect= new AlertDialog.Builder(MainActivity.this);
dialog.setMessage("Please Wait");;


You can do this very easily.

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

// set title
alertDialogBuilder.setTitle("Your Title");

// set dialog message
alertDialogBuilder.setMessage("Message here!").setCancelable(false);

// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();

// show it;

// After some action

If you have a reference to the AlertDialog somewhere else, you can still call alertDialog.dismiss(). This closes the dialog.