Java ConcurrentModificationException
我试图从地图集中删除所有元素,但我得到ConcurrentModificationException,所以我有一些复选框,它们的值在地图集中,但我想在按下submit按钮时删除所有地图集值 我的代码:Java ConcurrentModificationException,java,android,Java,Android,我试图从地图集中删除所有元素,但我得到ConcurrentModificationException,所以我有一些复选框,它们的值在地图集中,但我想在按下submit按钮时删除所有地图集值 我的代码: sumbit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(checkNoAttndance.isChecked
sumbit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(checkNoAttndance.isChecked()==true){
for (Map.Entry<Integer, Integer> mapEntry : checkBoxState
.entrySet()){
checkBoxState.remove(mapEntry.getKey());
}
}
else if (checkBoxState.isEmpty()) {
Toast.makeText(activity, "الرجاء اختيار اسماء الطلبة الغائبون ",
Toast.LENGTH_SHORT).show();
}
else {
ProgressDialog progressDialog = new ProgressDialog(activity);
progressDialog
.setMessage("جاري ارسال البيانات ، الرجاء الانتظار");
progressDialog.show();
SendListSync asynTask = new SendListSync(context, activity,
checkBoxState, progressDialog);
asynTask.execute();
}
}
});
sumbit.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
if(checkNoAttendance.isChecked()==true){
对于(Map.Entry mapEntry:checkBoxState
.entrySet()){
移除(mapEntry.getKey());
}
}
else if(checkBoxState.isEmpty()){
Toast.makeText(活动“Toast.makeText”,
吐司。长度(短)。show();
}
否则{
ProgressDialog=新建ProgressDialog(活动);
进展对话
.设置消息;
progressDialog.show();
SendListSync asynTask=新建SendListSync(上下文、活动、,
checkBoxState,progressDialog);
asynTask.execute();
}
}
});
更换
if(checkNoAttndance.isChecked()==true){
for (Map.Entry<Integer, Integer> mapEntry : checkBoxState.entrySet()){
checkBoxState.remove(mapEntry.getKey());
}
}
看看所有这些相关的问题…可能是重复的
if(checkNoAttndance.isChecked()){
checkBoxState.clear();
}