views:

354

answers:

1

I want to display a progress when the application start, then close progress when all data load completely. How can I do that?

+1  A: 

Use ProgressDialog to show Progress, Thread to load data and Handler to handle refresh UI.

In onCreate,

  mProgressDlg = ProgressDialog.show(this, "App_Name", "Loading data...", 
     true, false);
  new Thread(new Runnable(){
  public void run() {
   /*Load Data*/
   mProgressDlg.dismiss();
   hRefresh.sendEmptyMessage(REFRESH);
  }
 }).start();



Handler hRefresh = new Handler(){

@Override
public void handleMessage(Message msg) {
       switch(msg.what){
         case REFRESH:
                /*Refresh UI*/
                break;
       }
    }
};
bhatt4982