gpt4 book ai didi

java - startActivity 不等待单击警报按钮

转载 作者:行者123 更新时间:2023-11-30 05:10:43 25 4
gpt4 key购买 nike

我有一个对话框提示用户确认删除。

在用户点击删除后弹出一个简单的警告。我需要重定向到一个新 Activity ,但在我有机会在确认警报上单击“确定”之前,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();

谢谢!

最佳答案

想通了! JoeHz 是正确的。

这是遇到此问题的任何人的代码。

   AlertDialog.Builder alert = new AlertDialog.Builder(EventDetails.this);
alert.setMessage("Issue deleted!")
.setTitle(R.string.app_name)
.setIcon(R.drawable.logo)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(EventDetails.this, MyIssues.class);
startActivity(intent);
finish();
}
});

关于java - startActivity 不等待单击警报按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53800791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com