我已经创建了HashMap和JsonArrayRequest对象,如下所示。响应已成功检索但HashMap对象url_maps大小为零。我想在url_maps中使用for循环。
HashMap<String,String> url_maps = new HashMap<String, String>();
// Creating volley request obj for Banner
JsonArrayRequest bannerReq = new JsonArrayRequest(bannerUrl,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(msg, response.toString());
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
url_maps.put("static key", "static value );
} 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(msg, "Error: " + error.getMessage());
}
});
// Adding request to request queue
AppController.getInstance().addToRequestQueue(bannerReq);
答案 0 :(得分:0)
试试这个。
numpy.polynomial.legendre.Legendre
答案 1 :(得分:0)
也许你可以改变:
url_maps.put("static key", "static value );
为:
url_maps.put(obj.getString("static key"),obj.getString("static value"));