2011-12-23 10 views
-1

私はAndroidアプリケーションでProgressDialogを使用しました。 私はログイン、パスワード、Loginbtnをメインフォームに持っています。ログインすると、次の画面に移動し、ログインはインターネットとウェブドメインのベースになります。ログインすると、オンラインのサーバーにリクエストを送信します。真または偽の場合は、次の画面に移動します。サーバーから真または偽を取得しない限りProcessDialogを使用し、偽を取得すると処理が中止され、無効なユーザー名またはパスワードを示すメッセージが表示され、真の場合はプロセスを終了する必要がありますダイアログを開いて次の画面に移動すると、ProcessDialogが動作していますが、クリックするとダイアログが開始され、自動的に次の画面に移動しますが、戻るボタンを押すとプロセスダイアログが回転します。私はちょうど正しい方法でprocessDialogを使いたいです。 私のコードはProgressDialogが応答しなくなる

//start 
progressDialog = new ProgressDialog(DomainDownManagerActivity.this); 
      progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
      progressDialog.setMessage("Loading..."); 
      progressDialog.show(); 
      progressDialog.setProgress(100); 

> if (v==true){ 
//v has true 
Intent intent = new Intent(DomainDownManagerActivity.this,MainPanelActivity.class); 

startActivity(intent); 

    } 

    else{ 
    //set label of invalid user or pass 
    } 

画像が 負の私を評価されenter image description here

+0

を取り付けたのですか?あなたは答えを持っていない場合、否定率をしないでください! –

+0

http://eagle.phys.utk.edu/guidry/android/progressBarExample.html –

答えて

1
// write this line `new SomeTask(0).execute();` in your loginBtn.onCLick 
/** Inner class for implementing progress bar before fetching data **/ 

    private class SomeTask extends AsyncTask<Void, Void, Integer> 
    { 
     private ProgressDialog Dialog = new ProgressDialog(yourActivityClass.this); 
     @Override 
     protected void onPreExecute() 
     { 

     Dialog.setMessage("loading..."); 
     Dialog.show(); 
    } 

    @Override 
    protected Integer doInBackground(Void... params) 
    { 


      //Task for doing something 
// get data from php server if true then return 

      return 0; 
    } 

    @Override 
    protected void onPostExecute(Integer result) 
     { 



     if(result==0) 
      { 
//do some thing if true 
Intent intent = new Intent(DomainDownManagerActivity.this,MainPanelActivity.class); 
startActivity(intent); 
      } 

    // after completed finished the progressbar 
      Dialog.dismiss(); 
     } 

    } 
関連する問題