我得到了这个例外:
06-09 13:14:41.917: E/AndroidRuntime(630): java.util.ConcurrentModificationException
06-09 13:14:41.917: E/AndroidRuntime(630): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:573)
我使用以下内容EndlessAdapter
:
private class DemoAdapter extends EndlessAdapter {
private RotateAnimation rotate=null;
DemoAdapter(ArrayList<Outlets> outletList) {
super(new OutletListAdapter(VerticalsListActivity.this, outletList));
rotate=new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF,
0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
rotate.setDuration(600);
rotate.setRepeatMode(Animation.RESTART);
rotate.setRepeatCount(Animation.INFINITE);
}
@Override
protected View getPendingView(ViewGroup parent) {
View row=getLayoutInflater().inflate(R.layout.row, null);
View child=row.findViewById(android.R.id.text1);
child.setVisibility(View.GONE);
child=row.findViewById(R.id.throbber);
child.setVisibility(View.VISIBLE);
child.startAnimation(rotate);
return(row);
}
@Override
protected boolean cacheInBackground() throws Exception {
// TODO Auto-generated method stub
if(isMoreLoading){
try {
if(Project.isFilterEnabled){
getDownloadedData = (FetchAndParseData) new FetchAndParseData().execute(Project.searchUrl+"/pageno/"+ ++i);
}else{
getDownloadedData = (FetchAndParseData) new FetchAndParseData().execute(UrlConstants.OUTLETS_INFO_URL+Project.currentCityId+"/pageno/"+ ++i+"/verticalid/1");
}
inputStream = getDownloadedData.get();
XmlUtilities.parseAndLoadData(inputStream , mOutletXmlHandler);
outletList = Project.getOutletList();//Project.getOutletList();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return isMoreLoading;
}
@Override
protected void appendCachedData() {
// TODO Auto-generated method stub
adptr = (OutletListAdapter) getWrappedAdapter();
if(outletList.size()==20){
isMoreLoading=true;
}else{
isMoreLoading=false;
}
if(outletList!=null){
for (Outlets addThis : outletList) {
adptr.add(addThis);
}
}
}
}
现在,当一个列表包含少于 20 个元素并且我们滚动该列表时,它会引发上述异常。我在做什么错?