package com.example.administrator.myapplication;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//声明对象
AlertDialog dialog;
//
dialog =new AlertDialog.Builder(this).setTitle("Dialog对话框")
.setMessage("是否确定退出")
.setIcon(R.mipmap.ic_launcher)
.setPositiveButton("确定",null)
.setNegativeButton("取消",null)
.create();
dialog.show();
}
}
实操展示: