【发布时间】:2014-07-12 21:58:25
【问题描述】:
我创建了一个类,在她的办公室 preexecute 中扩展 AsyncTask 并显示 progressdialog,然后进入我调用 url 并转换为 JSON 字符串的 doinbackground,并在 postexecute 函数之后将 progressdialog 关闭,并且毕竟是加载和删除,但中间有一个圆圈,上面写着加载。看图片...IMAGE SCREEN看屏幕!
private class DownloadJSON extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// kriranje progressdialog-a
mProgressDialog = new ProgressDialog(Info.this.getActivity());
mProgressDialog.setMessage("Učitavanje informacija...");
mProgressDialog.setCancelable(false);
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
// Retrieve JSON Objects from the given URL address
jsonobject = JSONfunctions
.getJSONfromURL("http://77.105.36.203/objects.txt");
try {
// Locate the array name in JSON
jsonarray = jsonobject.getJSONArray("objects");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
map.put("ime", jsonobject.getString("ime"));
map.put("adresa", jsonobject.getString("adresa"));
map.put("email", jsonobject.getString("email"));
map.put("slika", jsonobject.getString("slika"));
// Set the JSON Objects into the array
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Greska:", e.getMessage());
e.printStackTrace();
//finish();
} catch (Exception a){
Log.e("errr", "ss");
a.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void args) {
listview = (ListView) getView().findViewById(R.id.listview);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(Info.this.getActivity(), arraylist);
listview.setAdapter(adapter);
mProgressDialog.dismiss();
}
}
【问题讨论】:
-
所以问题是即使在 onPostExecute() 之后还有一个加载指示器?问题/问题我不清楚。
-
是的,加载后结束 onPostExecute show progressdialog..
-
从您发布的图像和代码中,我没有看到 Asynctask 中包含正在加载消息的进度微调器代码声明。您应该检查您的 xml 布局和活动。