您的位置:首页 > 其它

AlertDialog使用

2015-11-23 16:05 246 查看

AlertDialog使用

new AlertDialog.Builder(MainActivity.this)
.setTitle("退出")
.setMessage("你确定退出吗")
.setCancelable(false)
.setNegativeButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "程序已结束", Toast.LENGTH_SHORT).show();
MainActivity.this.finish();
}
})
.setPositiveButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

}
})


.setCancleble(false)//设置返回键对其无效,不退出对话框,默认为ture

.setNegativeButton(“确定”, new DialogInterface.OnClickListener() {}//设置对话框确定按钮及相事件

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: