Android AlertDialog Single Button

后端 未结 9 1688
陌清茗
陌清茗 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:14

    You could use this:

    AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
    builder1.setTitle("Title");
    builder1.setMessage("my message");
    builder1.setCancelable(true);
    builder1.setNeutralButton(android.R.string.ok,
            new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    
    AlertDialog alert11 = builder1.create();
    alert11.show();
    

提交回复
热议问题