18 Ağustos 2017 Cuma

Volley JsonArrayRequest Sınıfı

constructor - url + responseListener + errorListener
İmzası şöyle
JsonArrayRequest(java.lang.String url, 
                 Response.Listener<JSONArray> listener, 
                 Response.ErrorListener errorListener)
Listener şöyledir.
class ResponseListener implements Response.Listener<JSONArray>
{
  @Override
  public void onResponse(JSONArray response)
  {
    ...
  }
}

class ErrorListener implements Response.ErrorListener
{
  @Override
  public void onErrorResponse(VolleyError error)
  {
    ...
  }
}
constructor - method + url + requestBody responseListener + errorListener
Şöyle yaparız.
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(
  Request.Method.POST,
  "http://abc.com.net/api/LoadDiaryTweetLinesByUser",
  obj,
  new Response.Listener<JSONArray>() {
    @Override
    public void onResponse(JSONArray response) {
      ...
    }
  },
  new Response.ErrorListener(){
    @Override
    public void onErrorResponse(VolleyError error){
      ...
    }
  }
);

Hiç yorum yok:

Yorum Gönder