user2401745 user2401745 - 1 year ago 142
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");;

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download