Android的AlertDialog单按钮按钮、Android、AlertDialog

2023-09-05 05:37:07 作者:坠入深海i

我想有而不是默认的AlertDialog生成器,只有一个按钮,上面写着确定或完成什么,yes和no。 可以与标准的AlertDialog来完成,否则我将不得不使用别的东西?

I'd like to have an AlertDialog builder that only has one button that says OK or Done or something, instead of the default yes and no. Can that be done with the standard AlertDialog, or would I have to use something else?

推荐答案

难道不就是要通过只使用一个积极的按钮来完成?

Couldn't that just be done by only using a positive button?

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Look at this dialog!")
       .setCancelable(false)
       .setPositiveButton("OK", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                //do things
           }
       });
AlertDialog alert = builder.create();
alert.show();
 
精彩推荐
图片推荐