Simple Android native Cancel the dialog box usage

Project out of a pit father, the sudden cancellation to add a confirmation dialog. But because it is the first edition, UI design aspects are not planned. That by native chanting, suddenly I found native forgotten how to write, how to write search to find a meal, here to record it.

new AlertDialog.Builder(this).setTitle("确定取消关联吗")
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                           //点击确定触发的事件
                    }
                })
                .setNegativeButton("返回", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                            //点击取消触发的事件
                    }
                }).show();

 

Guess you like

Origin blog.csdn.net/weixin_38322371/article/details/88715804