Search This Blog

Monday, March 17, 2014

Call ProgressDialog inside onCreate


  • Add 
             import android.app.ProgressDialog;
  • Declare progress dialog  globally in this page
         ProgressDialog progressDialog;
  • Add some code in the onCreate method before task start
        progressDialog = new ProgressDialog(ClassName.this);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setIndeterminate(false);
progressDialog.show(); 
  •      Now you can add you Thread. Write your necessary code inside Thread.After finsih you tast and before leaving Thread,please dismiss your progressDialog.

             new Thread(new Runnable() {
public void run() {
                                              /* Wirte your Codes which take long time and are not in the main
                                                  thread  i.e. HttpClient call
                                                */
                                              progressDialog.dismiss();

}

}).start();

No comments:

Post a Comment