嗨,我有一个 Asynctask,唯一的问题是屏幕是空白的,直到所有内容都加载完毕,所以我创建了一个 loadingcell 视图,但我想知道如何让它显示加载视图,直到所有内容都加载完毕。
这是我尝试过的,但它不起作用
public class PostTask extends AsyncTask<Void, String, Boolean> {
@Override
protected Boolean doInBackground(Void... params) {
boolean result = false;
loadFixtures();
publishProgress("progress");
loadResultsFeed();
publishProgress("progress");
loadNewsFeed();
publishProgress("progress");
return result;
}
protected void onProgressUpdate(String... progress) {
StringBuilder str = new StringBuilder();
for (int i = 1; i < progress.length; i++) {
str.append(progress[i] + " ");
loadingView = LayoutInflater.from(getBaseContext()).inflate(R.layout.loadingcell,
null);
}
}
@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
Log.v("BGThread", "begin fillin data");
FillData();
}
}