android dialog弹出框有哪些
1个回答
展开全部
private void dialog1(){
AlertDialog.Builder builder=new AlertDialog.Builder(this); //先得到构造器
builder.setTitle("提示"); //设置标题
builder.setMessage("是否确认退出?"); //设置内容
builder.setIcon(R.mipmap.ic_launcher);//设置图标,图片id即可
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { //设置确定按钮
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); //关闭dialog
Toast.makeText(MainActivity.this, "确认" + which, Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { //设置取消按钮
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(MainActivity.this, "取消" + which, Toast.LENGTH_SHORT).show();
}
});
builder.setNeutralButton("忽略", new DialogInterface.OnClickListener() {//设置忽略按钮
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(MainActivity.this, "忽略" + which, Toast.LENGTH_SHORT).show();
}
});
//参数都设置完成了,创建并显示出来
builder.create().show();
}
AlertDialog.Builder builder=new AlertDialog.Builder(this); //先得到构造器
builder.setTitle("提示"); //设置标题
builder.setMessage("是否确认退出?"); //设置内容
builder.setIcon(R.mipmap.ic_launcher);//设置图标,图片id即可
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { //设置确定按钮
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); //关闭dialog
Toast.makeText(MainActivity.this, "确认" + which, Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { //设置取消按钮
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(MainActivity.this, "取消" + which, Toast.LENGTH_SHORT).show();
}
});
builder.setNeutralButton("忽略", new DialogInterface.OnClickListener() {//设置忽略按钮
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Toast.makeText(MainActivity.this, "忽略" + which, Toast.LENGTH_SHORT).show();
}
});
//参数都设置完成了,创建并显示出来
builder.create().show();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |