AsyncTaskを使用して進行状況ダイアログにロードします。UIスレッドのコントロールを更新するには、ハンドラーを宣言する必要があります。
例:
private Handler handler = new Handler();
final ProgressDialog pd = new ProgressDialog(this);
pd.setTitle("Getting topics..");
pd.setMessage("Please while topics are retrieved");
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setIndeterminate(true);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
GetTopics();
return null;
}
@Override
protected void onPreExecute() {
pd.show();
super.onPreExecute();
}
@Override
protected void onPostExecute(Void result) {
BindTopics();
pd.dismiss();
handler.post(new Runnable() {
public void run() {
// update UI
// remove loading view
// load details of topics
}
});
super.onPostExecute(result);
}
}.execute();