Android AlertDialog Single Button

后端 未结 9 1702
陌清茗
陌清茗 2020-12-12 12:08

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 Al

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 12:17

    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();
    

提交回复
热议问题