app/src/main/java/com/yanzhenjie/alertdialog/sample/MainActivity.java
private void onCommonClick() {
        AlertDialog.build(this)
                .setTitle("标题")
                .setMessage("提示信息")
                .setNeutralButton("忽略", (dialog, which) -> {
                    Toast.makeText(MainActivity.this, "点击了忽略", Toast.LENGTH_SHORT).show();
                })
                .setNegativeButton("取消", (dialog, which) -> {
                    Toast.makeText(MainActivity.this, "点击了取消", Toast.LENGTH_SHORT).show();
                })
                .setPositiveButton("好的", (dialog, which) -> {
                    Toast.makeText(MainActivity.this, "点击了确定", Toast.LENGTH_SHORT).show();
                })
                .show();

        //  Button被点击后，不调用dialog.dismiss()，因为AlertDialog会自动调用。
    }
private void onCommonClick() {
        AlertDialog.build(this)
                .setTitle("标题")
                .setMessage("提示信息")
                .setNeutralButton("忽略", (dialog, which) -> {
                    Toast.makeText(MainActivity.this, "点击了忽略", Toast.LENGTH_SHORT).show();
                })
                .setNegativeButton("取消", (dialog, which) -> {
                    Toast.makeText(MainActivity.this, "点击了取消", Toast.LENGTH_SHORT).show();
                })
                .setPositiveButton("好的", (dialog, which) -> {
                    Toast.makeText(MainActivity.this, "点击了确定", Toast.LENGTH_SHORT).show();
                })
                .show();

        //  Button被点击后，不调用dialog.dismiss()，因为AlertDialog会自动调用。
    }
private void onCommonClick ( ) { AlertDialog . build ( this ) . setTitle ( "标题") . setMessage ( "提示信息") . setNeutralButton ( "忽略", (d i l og, wh i h) -> Toast . makeText ( MainActivity . this , "点击了忽略", Toast.LE N TH_SH O RT).show(); } ) . setNegativeButton ( "取消", (d i l og, wh i h) -> Toast . makeText ( MainActivity . this , "点击了取消", Toast.LE N TH_SH O RT).show(); } ) . setPositiveButton ( "好的", (d i l og, wh i h) -> Toast . makeText ( MainActivity . this , "点击了确定", Toast.LE N TH_SH O RT).show(); } ) . show ( ) ; //  Button被点击后，不调用dialog.dismiss()，因为AlertDialog会自动调用。 }
显示正常用法的按钮。
显示正常用法的按钮。