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 people say with a AlerDialog but I am not sure. This alert would have two buttons: "Confirm" and "Cancel".
Thanks in advace.
AlertDialog suits your needs, and simple to implement.
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setCancelable(true);
builder.setTitle("Title");
builder.setMessage("Message");
builder.setPositiveButton("Confirm",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog dialog = builder.create();
dialog.show();
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() {
public void onClick(DialogInterface dialog, int id) {
// CONFIRM
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// CANCEL
}
});
// Create the AlertDialog object and return it
return builder.create();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With