AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Title of the alert dialog");
builder.setMessage("Message to be displayed in the alert dialog");
builder.setPositiveButton("Positive Button", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Code to be executed when the positive button is clicked
}
});
builder.setNegativeButton("Negative Button", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Code to be executed when the negative button is clicked
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
1条答案
按热度按时间jgwigjjp1#
正常的警报对话框如下所示
您可以对此进行更多自定义。请查看Android documentation中的AlertDialog类