private void setAialog() {
//创建一个AlertDialog
AlertDialog.Builder builder = new AlertDialog.Builder(SettingActivity.this);
//设置标题
builder.setTitle("退出提示");
//设置内容
builder.setMessage("退出登录后,你将不能再接单,发单了!");
//设置按钮
builder.setPositiveButton("确认退出",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
spf.edit().putBoolean("login",false).commit();
spf.edit().putString("name",null).commit();
startActivity(new Intent(SettingActivity.this,MainActivity.class));
System.exit(0);
}
});
//设置按钮
builder.setNegativeButton("取消退出", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog dialog = builder.create();
//显示出来
dialog.show();
}