如何在 Android Studio 中显示弹出窗口以确认订单? [英] How to show a pop up in Android Studio to confirm an order?
本文介绍了如何在 Android Studio 中显示弹出窗口以确认订单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户在我的应用中下订单(按下按钮)时,我想显示一个弹出窗口或提示,以便他们确认产品的数量和价格.我怎样才能做到这一点??有些人用 AlerDialog 说,但我不确定.此警报将有两个按钮:确认"和取消".
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".
提前致谢.
推荐答案
AlertDialog 适合您的需求,并且易于实施.
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();
这篇关于如何在 Android Studio 中显示弹出窗口以确认订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文