Alert Dialog Boxes
Sometimes the application you are creating, want 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.
In order to make an alert dialog, you need to make an object of AlertDialogBuilder class which an inner class of AlertDialog. The syntax to be followed is given below.
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
Now to set the positive, negative and neutral buttons using the object of the AlertDialogBuilder class. Its syntax is
alertDialogBuilder.setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener);
alertDialogBuilder.setNegativeButton(CharSequence text, DialogInterface.OnClickListener listener);
alertDialogBuilder.setNeutralButton(CharSequence text, DialogInterface.OnClickListener listener);
Comments
Post a Comment