【发布时间】:2018-12-16 09:03:31
【问题描述】:
我有一个对话框提示用户确认删除。
用户点击删除后会弹出一个简单的警报。我需要重定向到一个新的活动,但在我有机会在确认警报上单击“确定”之前,startActivity 会启动。我已经添加了一条评论,它搞砸了。有什么想法吗?
final AlertDialog.Builder alert = new
AlertDialog.Builder(EventDetails.this);
alert.setMessage("Are you sure you want to delete
your Issue?")
.setTitle(R.string.app_name)
.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Configs.showPD("Please wait...", EventDetails.this);
eventObj.put(Configs.ISSUES_DELETED_BY, "Deleted By User");
Date now = new Date();
eventObj.put(Configs.ISSUES_DELETED_DATE, now);
eventObj.put(Configs.ISSUES_DELETED, true);
eventObj.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Configs.hidePD();
Configs.simpleAlert("Issue deleted!", EventDetails.this);
// Does not wait for me to click "OK" after "Issue deleted!"
Intent intent = new Intent(EventDetails.this, MyIssues.class);
startActivity(intent);
}
}
});
}
})
.setNegativeButton("Cancel", null)
.setIcon(R.drawable.logo);
alert.create().show();
谢谢!
【问题讨论】:
-
simpleAlert 代码在哪里
-
simpleAlert() 内部可能有一些显示警报的代码。在那个电话中,我愿意打赌有一个地方可以进行回调。那就是 startActivity() 调用。除了在开始活动之前显示它之外,您在这里所拥有的可能与警报无关。
-
你们俩都是对的。谢谢!