You should load data in an AsyncTask and update your interface when the data finishes loading.
You could even start a new activity in your AsyncTask's onPostExecute()
method.
More specifically, you will need a new class that extends AsyncTask:
public class MyTask extends AsyncTask<Void, Void, Void> {
public MyTask(ProgressDialog progress) {
this.progress = progress;
}
public void onPreExecute() {
progress.show();
}
public void doInBackground(Void... unused) {
... do your loading here ...
}
public void onPostExecute(Void unused) {
progress.dismiss();
}
}
Then in your activity you would do:
ProgressDialog progress = new ProgressDialog(this);
progress.setMessage("Loading...");
new MyTask(progress).execute();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…