//1.创建普通对话框
AlertDialog dialog = new AlertDialog.Builder(this).setTitle("Dialog对话框") //设置标题
.setMessage("是否确定退出") //设置提示信息
.setIcon(R.mipmap.ic_launcher) //设置图标
.setPositiveButton("确定", null) //添加确定按钮
.setNegativeButton("取消", null) //设置取消按钮
.create();
dialog.show();
//2.创建单选对话框
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("请选择性别") //设置标题
.setIcon(R.mipmap.ic_launcher) //设置图标
.setSingleChoiceItems(new String[]{"男", "女"}, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setPositiveButton("确定", null) //添加确定按钮
.create();
dialog.show();
//3.创建多选对话框
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("请添加兴趣爱好") //设置标题
.setIcon(R.mipmap.ic_launcher) //设置图标
.setMultiChoiceItems(new String[]{"旅游","美食","汽车","购物"},null,null)
.setPositiveButton("确定", null) //添加确定按钮
.create();
dialog.show();
//4.创建进度条对话框
ProgressDialog prodialog = new ProgressDialog(this);
prodialog.setTitle("进度条对话框");
prodialog.setIcon(R.mipmap.ic_launcher);
prodialog.setMessage("正在下载,请稍后");
//设置水平进度条
prodialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
prodialog.show();