Skip to content Skip to sidebar Skip to footer

How To Show A Pop Up In Android Studio To Confirm An Order?

I want to show a pop up or a prompt when a user makes an order in my app (pressing a button) for them to confirm the amount of the product and the price. How can I do that?? Some p

Solution 1:

AlertDialog suits your needs, and simple to implement.

   AlertDialog.Builderbuilder=newAlertDialog.Builder(mContext);
            builder.setCancelable(true);
            builder.setTitle("Title");
            builder.setMessage("Message");
            builder.setPositiveButton("Confirm",
                    newDialogInterface.OnClickListener() {
                        @OverridepublicvoidonClick(DialogInterface dialog, int which) {
                        }
                    });
            builder.setNegativeButton(android.R.string.cancel, newDialogInterface.OnClickListener() {
                @OverridepublicvoidonClick(DialogInterface dialog, int which) {
                }
            });

            AlertDialogdialog= builder.create();
            dialog.show();

Solution 2:

This: Dialogs | Android Developers

What exactly are you not sure about? It's as simple as 1, 2, 3

AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.confirm_dialog_message)
           .setTitle(R.string.confirm_dialog_title)
           .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
               publicvoidonClick(DialogInterface dialog, int id) {
                   // CONFIRM
               }
           })
           .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
               publicvoidonClick(DialogInterface dialog, int id) {
                   // CANCEL
               }
           });
    // Create the AlertDialog object and return itreturn builder.create();

Solution 3:

You could use the alert builder for this:

new AlertDialog.Builder(context)
    .setTitle("Confirm Order")
    .setMessage("Are you sure?")
    .setPositiveButton(@"Confirm", new DialogInterface.OnClickListener() {
        publicvoidonClick(DialogInterface dialog, int which) { 
            // continue with delete
        }
     })
    .setNegativeButton(@"Cancel", new DialogInterface.OnClickListener() {
        publicvoidonClick(DialogInterface dialog, int which) { 
            // do nothing
        }
     })
    .setIcon(android.R.drawable.ic_dialog_alert)
     .show();

Post a Comment for "How To Show A Pop Up In Android Studio To Confirm An Order?"