

SetOnCancelListener(DialogInterface.OnCancelListener onCancelListener) The selected option will be notified by the listener

This method sets list of items to be displayed in the dialog as the content. SetMultiChoiceItems(CharSequence items, boolean checkedItems, DialogInterface.OnMultiChoiceClickListener listener) This method sets the message to be displayed in the alert dialog

This method sets the property that the dialog can be cancelled or not This method set the icon of the alert dialog box. Its syntax isĪtPositiveButton(CharSequence text,ĭialogInterface.OnClickListener listener)ĪtNegativeButton(CharSequence text,Īpart from this, you can use other functions provided by the builder class to customize the alert dialog. Now you have to set the positive (yes) or negative (no) button using the object of the AlertDialogBuilder class. Its syntax is given belowĪlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this) In order to make an alert dialog, you need to make an object of AlertDialogBuilder which an inner class of AlertDialog. Some times in your application, if you wanted to ask the user about taking a decision between yes or no in response of any particular action taken by the user, by remaining in the same activity and without changing the screen, you can use Alert Dialog. A Dialog is small window that prompts the user to a decision or enter additional information.
