天天看点

support包下的AlertDialog

只需导包的时候注意就行;

import android.content.DialogInterface;      
import android.support.v7.app.AlertDialog;      

代码:

AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            builder.setIcon(R.mipmap.ic_launcher);
            builder.setTitle("温馨提示");
            builder.setMessage("你确定退出应用吗?");
            builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                    android.os.Process.killProcess(android.os.Process.myPid());
                }
            });
            builder.setNegativeButton("取消", null);
            AlertDialog dialog = builder.create();
            dialog.show();
           

效果图:

support包下的AlertDialog

继续阅读