startActivity不等待单击警报按钮

时间:2018-12-16 09:03:32

标签: java android alert

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

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

谢谢!

1 个答案:

答案 0 :(得分:0)

想通了! JoeHz是正确的。

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

def useful_stuff(cls):
  class LocalClass(cls):
    def better_foo(self):
      print('better foo')
  return LocalClass

@useful_stuff
class MyClass:
  def foo(self):
    print('foo')
相关问题