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.setTitle("Detecting.....");
dialog.setMessage("Please Wait");
dialog.show();
Really depends on what "action" is being performed:
This way you get a frozen UI until
timeConsumingDetectMethod()
finishes.However, the following way runs the action in background, while a very responsive dialog is shown. Also, cancels the action when dialog is cancelled.
You can try Custom Dialog design u r on Dialog and use it as u wish to use them
You can call
alertDialog .dismiss ()
after any action.Implement a timer and set it to dismiss the DialogBox after a few seconds.
You can do this very easily.
If you have a reference to the
AlertDialog
somewhere else, you can still callalertDialog.dismiss()
. This closes the dialog.You can also write crocboy's code like this:
It does exactly the same thing, it's just more compact.