0
public Context ctx;
 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.ctx = this;
            //another code......)

        send = (Button)findViewById(R.id.wyslij_zapytanie_ofertowe);
        send.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                ProgressDialog dialog = ProgressDialog.show(ctx, "Loading", "Please wait...", true);
                try {   
                    GMailSender sender = new GMailSender("dasdda@gmail.com", "ddx");
                    sender.sendMail("This is Subject",   
                            "This is Body",   
                            "staxxxowe@gmail.com",   
                            "xxxyk@gmail.com");   
                  dialog.dismiss();
                } catch (Exception e) {   
                    Log.e("SendMail", e.getMessage(), e);
                    dialog.dismiss();
                } 
            }
        });

我也尝试 ctx put ClassName.class 并且也不起作用。有人知道如何解决这个问题吗?

4

2 回答 2

1

你的问题很可能是你打电话dialog.dismiss();后“立即”打电话dialog.show(),这可能会导致这种“不显示”的效果。

dialog.setButton("Cancel", new DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int which) {
      dialog.dismiss();
   }
});
于 2012-07-03T18:30:48.790 回答
0

它甚至可能在它被创建之前就被解雇了,因为你只需要几行就可以调用dialog.dismiss()

于 2012-07-03T18:22:44.290 回答