我目前正在使用Volley,通过以下代码提取JSON内容。
JsonArrayRequest servicesStatus = new JsonArrayRequest(url1,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
hidePDialog();
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
// Having obj to process further
} catch (JSONException e) {
e.printStackTrace();
}
}
// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePDialog();
}
});
现在,我希望为新URL提供一个JSON处理程序,并在从两个URL成功下载后关闭该对话框。
我试图复制粘贴上面的内容,并用url1替换为url2和其他jsonarrayrequest名称。并在第二个中添加了hideDialog()。但是第二个根本没有被调用。