我asynctask
经常使用但是这次它不起作用!我有一个 UI 包含一个viewpager
和fragments
. 填充视图大约需要 3 秒。现在我想显示 ProgressDialog 直到它使用AsyncTask
. 但是ProgressDialog
没有显示!!!!
任何人都可以告诉我解决方案吗?谢谢
onCreate(...){
setContentView(...)
new LoadUI(MyActivity.this).execute();
}
public class LoadUI extends AsyncTask<Void, Void, Void>{
ProgressDialog pd;
Context context;
public LoadUI(Context mContext) {
this.context = mContext;
pd = new ProgressDialog(mContext);
aViewPager = (ViewPager) findViewById(R.id.aPagerDay);
}
@Override
protected void onPreExecute() {
pd.show();
}
@Override
protected Void doInBackground(Void... params) {
//Create ViewPager
//Create pagerAdapter
return null;
}
@Override
protected void onPostExecute(Void result) {
if (pd.isShowing()) {
pd.dismiss();
}
super.onPostExecute(result);
}
}