我必须用带参数的Json数据来扩展listview。但它给出了错误2.onErrorResponse:MainActivity。我使用String Request和Json Request多次检查但是没有一个正在工作......请帮助!!!
JsonArrayRequest movieReq = new JsonArrayRequest(Request.Method.POST,url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
hidePDialog();
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
title_array.add(obj.getString("amount").toString());
notice_array.add(obj.getString("payment_id").toString());
title1_array.add(obj.getString("invoice_id").toString());
notice1_array.add(obj.getString("payment_date").toString());
notice2_array.add(obj.getString("movieName").toString());
notice3_array.add(obj.getString("source").toString());
adapter = new CustomBaseAdapter(Transaction.this, title_array, notice_array,title1_array,notice1_array,notice2_array,notice3_array);
list.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePDialog();
}
}){
@Override
protected Map<String, String> getParams()
throws com.android.volley.AuthFailureError {
HashMap<String, String> params = new HashMap<String, String>();
params.put("user_id", user_id);
params.put("user_type", User_type);
return params;
}
};
// Adding request to request queue
requestQueue.add(movieReq);