我有一個JSON響應,我打印在一個listview.It打印從JSON的值,但所有的值不能正確打印。有些JSON值打印在錯誤的地方。JSON響應不正確打印在Android Listview使用凌空
JSON響應:
```
[
{
"HouseNo":"33333333",
"AreaName":"ghfhgfhg",
"Landmark":"",
},
{
"HouseNo":"33333333",
"AreaName":"gfhgfh",
"Landmark":"",
}
]
```
這是用於提取特定值的代碼:
StringRequest stringRequest = new StringRequest(Request.Method.POST,url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, response.toString());
hidePDialog();
try {
JSONArray jsonarray = new JSONArray(response);
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject obj = jsonarray.getJSONObject(i);
Customer customer = new Customer();
customer.setTitle(obj.getString("HouseNo"));
customer.setSerial(obj.getString("AreaName"));
customer.setService(obj.getString("Landmark"));
customerList.add(customer);
}
} catch (JSONException e) {
e.printStackTrace();
}
// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePDialog();
}
})
一些響應打印OK;但是在某些印刷迴應的地方印刷了其他迴應。如何解決這個問題?
顯示您的適配器代碼 – Vickyexpert
也添加您的客戶模型類 – Pavya