2011-08-30 38 views
0

私のAndroid搭載アプリケーションに問題があります。ユーザーがボタンをクリックすると、進行状況ダイアログが必要になります。問題は、この進捗ダイアグラムが表示されず、問題がどこにあるのか分からないということです。誰でも助けてくれますか?これは私のコードです:なぜProgressDialogが表示されないのですか?

public void btnSend_onClick(View c) { 

     dialogwait = ProgressDialog.show(SendPhoto.this, "", 
      "Loading. Please wait...", true); dialogwait.show(); 

     //dialogwait = ProgressDialog.show(this, "Loading..", "Please wait...", true,  false); 
      Handler message = new Handler() { 

       @Override 
       public void handleMessage(Message msg) { 
        switch (msg.what) { 

        } 
        dialogwait.cancel(); 

       } 
      }; 

      message.sendEmptyMessageDelayed(0, 3 * 1000); 

     surname = eTxtSurname.getText().toString(); 
     name = eTxtName.getText().toString(); 
     email1 = eTxtEmail.getText().toString(); 
     phone1 = eTxtPhone.getText().toString(); 

     shop_id = Singleton.getInstance().getShop(); 

     boolean ok = isEmailValid(eTxtEmail.getText().toString()); 
     System.out.println("ok e" + ok); 

     System.out.println("ok e" + surname); 
     System.out.println("ok e" + name); 
     System.out.println("ok e" + email1); 
     System.out.println("ok e" + phone1); 

     sendimg.setVisibility(View.INVISIBLE); 

     if ((surname.isEmpty()) || (name.isEmpty()) || (email1.isEmpty()) 
       || (phone1.isEmpty())) { 

      Toast.makeText(this, error_complete, Toast.LENGTH_SHORT).show(); 
      sendimg.setVisibility(View.VISIBLE); 
     } else if (ok != true) { 
      dialogwait.cancel(); 
      Toast.makeText(getBaseContext(), email_valid, Toast.LENGTH_SHORT) 
        .show(); 
      sendimg.setVisibility(View.VISIBLE); 
     } else { 
      String r = executeMultiPartPost(surname, name, email1, phone1, 
        shop_id); 

      if (r.equals("ok")) { 

       alertDialog = new AlertDialog.Builder(this).create(); 
       alertDialog.setTitle(sent_ok); 
       alertDialog.setMessage(alertmsg); 
       alertDialog.setButton("OK", 
         new DialogInterface.OnClickListener() { 
          public void onClick(DialogInterface dialog, 
            int which) { 
           Intent i = new Intent(getBaseContext(), 
             com.Xperiaproject.Participe.class); 
           startActivity(i); 
           return; 
          } 
         }); 
       alertDialog.show(); 

      } 
     } 
    } 
+0

使用 'AsyncTask'を使用して、HTTP([このポスト]を見ています://www.androidsnippets.com/grab-a-url-source-with-progressDialog-and-asynctask)。 –

答えて

1

これは私のために働いている:

ProgressDialog loader = ProgressDialog.show(this, "", "Working...", true); 
      new Thread(new Runnable(){ 
       public void run() { 
        //do the work here 
       if(loader!=null){ 
        loader.dismiss();}} 
      }).start();  

そうAsyntask(アディルのコメント)

関連する問題