当我只调用wpCategories = JsonToElement.getllAllCategory();
按钮onClick
方法时,它工作正常。(wpCategories
填满数据)。但是当我把它放在 a 中时asynctask
, wpCategories
返回 null。(doInBackground
不是被调用吗?)
这是我关于点击方法的按钮:
public void onImageGridClick(View view) {
new GetJsonElementTask().execute();
Intent intent = new Intent(this, CategoryGridActivity.class);
intent.putParcelableArrayListExtra(Extra.IMAGES, wpCategories);
startActivity(intent);
}
和异步任务:
private class GetJsonElementTask extends AsyncTask<Void, Integer, String> {
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(HomeActivity.this, "",
"Loading...");
}
@Override
protected String doInBackground(Void... arg0) {
wpCategories = JsonToElement.getllAllCategory();
return null;
}
@Override
protected void onPostExecute(String value) {
progressDialog.dismiss();
}
@Override
protected void onProgressUpdate(Integer... progress) {
Log.v("DEBUG_LOG", "In onProgressUpdate");
}
}