Created
July 20, 2016 16:15
-
-
Save roshanpal/a736b1143df8c1b80e99a1f97ed52522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JsonArrayRequest request = new JsonArrayRequest(url, new Response.Listener<JSONArray>() { | |
@Override | |
public void onResponse(JSONArray response) { | |
for (int i = 0; i < response.length(); i++) { | |
try { | |
JSONObject jp = response.getJSONObject(i); | |
Post p = new Post( | |
jp.getInt("userId"), | |
jp.getInt("id"), | |
jp.getString("title"), | |
jp.getString("body") | |
); | |
mPosts.add(p); | |
} catch (JSONException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
}, new Response.ErrorListener() { | |
@Override | |
public void onErrorResponse(VolleyError error) { | |
Toast.makeText(getActivity(), "Error", Toast.LENGTH_SHORT).show(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment