0
我有一個Android程序使用Volley StringRequest與動態ListView,但 我有一個情況,在Android監視器後,我得到所有的數據它仍然循環到下一個索引。我只想在我已經獲得所有數據時停止循環。Android排球停止或限制response.length()循環
MyActivity.java
[email protected]
public void onResponse(String response) {
Log.d("RES-GET:", response);
for(int i = 0; i<response.length();i++){
try { //mengubah response dari String -> JsonObject & diparsing
//Parse String to JSONObject
JSONObject objUser = new JSONObject(response);
Log.d("Dep-JSONObj", objUser.toString());
...
//view departement
Departement dept = new Departement(dep.getNamadept(), dep.getSubtitle(), dep.getDetail());
deptList.add(dept); //method from other activity to set view departement
} catch (JSONException e) {
e.printStackTrace();
//Log.e("My App", "Could not parse malformed JSON: \"" + response + "\"");
}
}mAdapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(DeptActivity.this, "Service getdepartment() : GAGAL !", Toast.LENGTH_LONG).show();
}
}); ...
在該圖片,我有2索引(索引0和索引1),但它仍然循環直到458個循環。索引1執行時如何停止循環?
'爲(解析相同的JSON int i = 0; i
njzk2