接着 上一篇 https://www.cnblogs.com/Nora-F/p/10320335.html
public class CustomArrayRequest extends Request<JSONArray> { private Listener<JSONArray> listener; private Map<String, String> params; public CustomArrayRequest(String url, Map<String, String> params, Listener<JSONArray> reponseListener, ErrorListener errorListener) { super(Method.GET, url, errorListener); this.listener = reponseListener; this.params = params; } public CustomArrayRequest(int method, String url, Map<String, String> params, Listener<JSONArray> reponseListener, ErrorListener errorListener) { super(method, url, errorListener); this.listener = reponseListener; this.params = params; } protected Map<String, String> getParams() throws com.android.volley.AuthFailureError { return params; }; @Override protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) { try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(new JSONArray(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JSONException je) { return Response.error(new ParseError(je)); } } @Override protected void deliverResponse(JSONArray response) { // TODO Auto-generated method stub listener.onResponse(response); } }
其实只是改变了一下 浅蓝 位置 的类型