我当前从 web 服务检索数据的代码如下:
try{
for(int i = 0; i <= list.size() - 1; i++){
SoapObject request = new SoapObject(NAMESPACE + "/", "get_all");
request.addProperty("host", host);
request.addProperty("user", user);
request.addProperty("pass", pass);
request.addProperty("bd", bd);
request.addProperty("id", list.get(i));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, 60000);
try {
androidHttpTransport.call(URL + "/get_all", envelope);
} catch (Exception e) {
Log.e("Error HH:", e.toString());
break;
}
SoapObject rep = (SoapObject) envelope.bodyIn;
JSONArray jr = new JSONArray(rep.getPropertyAsString(0));
JSONObject jb = (JSONObject) jr.get(0);
db.update_text(jb.getString("text_priority"), jb.getInt("id"));
updateLabel("Importing id: " + jb.getString("id"));
publishProgress((i * 100) / list.size());
}
}catch (Exception e) {
Log.e("Error H:", e.toString());
}
它在标签中正确显示以下内容:
“导入id:1”
“导入id:2”
“导入id:3”
“导入id:4”
“导入id:5”
“导入id:6”
它工作正常。虽然,只要调用完美完成,我想删除变量“list”中的 ID。
try {
androidHttpTransport.call(URL + "/get_all", envelope);
list.remove(list.get(i));
} catch (Exception e) {
Log.e("Error HH:", e.toString());
break;
}
但是,使用此代码,我的标签输出如下:
“导入id:1”
“导入id:3”
“导入id:5”
“导入id:7”
我也试过这个:
try {
androidHttpTransport.call(URL + "/get_all", envelope);
list.remove(i);
} catch (Exception e) {
Log.e("Error HH:", e.toString());
break;
}
但是我得到了相同的结果,谁能告诉我为什么?谢谢。