에 표시됩니다 내가 webservice.I에 문제가 recyclerView으로 된 JSONObject를 다운로드하여 구문 분석 및 디스플레이 있어요. Volley 라이브러리를 사용하고 있습니다. 내 코드는 다음과 같습니다 콘서트는 3이고 내 recyclerView 정확히 3 콘서트를 가지고있는 동안 responseJSONArray의은 ListView에
@Override
protected List<Concert> doInBackground(String... params) {
final List<Concert> concerts = new ArrayList<>();
StringRequest request = new StringRequest(Request.Method.GET, "http://krakowskascenamuzyczna.pl/api/koncerty/future/",
new com.android.volley.Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject responseJSONObject = new JSONObject(response);
String arrayString = responseJSONObject.getJSONArray("posts").toString();
JSONArray responseJSONArray = new JSONArray(arrayString);
Concert tempConcert;
Log.e(TAG, "onResponse: " + responseJSONArray.length());
for (int i = 0; i < responseJSONArray.length(); i++) {
tempConcert = new Concert(responseJSONArray.getJSONObject(i).getJSONArray("attachments").getJSONObject(0).getJSONObject("images").getJSONObject("full").getString("url"),
responseJSONArray.getJSONObject(i).getString("content"),
responseJSONArray.getJSONObject(i).getString("date"),
responseJSONArray.getJSONObject(i).getString("title"),
responseJSONArray.getJSONObject(i).getInt("id"),
responseJSONArray.getJSONObject(i).getString("type"),
responseJSONArray.getJSONObject(i).getJSONObject("custom_fields").getJSONArray("typ").getInt(0));
concerts.add(tempConcert);
Log.e(TAG, "onResponse: size" + concerts.size());
}
길이는 10입니다. 왜 모든 다운로드 콘서트가 목록에 추가되지 않습니까?
합니까 로그 : 내부 루프 인쇄 10 회 "onResponse 크기"?? – sJy
10 가지 답변을 얻으려면 RecyclerView의 구현을 살펴야합니다. –
onResponse : 크기 ". 3 번 내가 org.json.JSONException를 얻을 것을 발견 인쇄 : 인덱스 0 범위를 벗어 [0..0) – Bartos