Reputation: 2651
I want to display a progress when the application start, then close progress when all data load completely. How can I do that?
Upvotes: 1
Views: 2849
Reputation: 8054
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;
}
}
};
Upvotes: 3