1.1声明RequestQueue
声明一个新的RequestQueue对象
[java] view plain copy print?
private RequestQueue mRequestQueue;
在onCreate初始化mRequestQueue
mRequestQueue = Volley.newRequestQueue(this);
1.2 声明并使用Request
JsonObjectRequest jr = new JsonObjectRequest(Request.Method.GET,url,null,new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.i(TAG,response.toString());
parseJSON(response);
va.notifyDataSetChanged();
pd.dismiss();
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i(TAG,error.getMessage());
}
});
mRequestQueue.add(jr);
声明一个新的RequestQueue对象
[java] view plain copy print?
private RequestQueue mRequestQueue;
在onCreate初始化mRequestQueue
mRequestQueue = Volley.newRequestQueue(this);
1.2 声明并使用Request
JsonObjectRequest jr = new JsonObjectRequest(Request.Method.GET,url,null,new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.i(TAG,response.toString());
parseJSON(response);
va.notifyDataSetChanged();
pd.dismiss();
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i(TAG,error.getMessage());
}
});
mRequestQueue.add(jr);