Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ConcurrentModificationException_Java_Android - Fatal编程技术网

Java ConcurrentModificationException

Java ConcurrentModificationException,java,android,Java,Android,我试图从地图集中删除所有元素,但我得到ConcurrentModificationException,所以我有一些复选框,它们的值在地图集中,但我想在按下submit按钮时删除所有地图集值 我的代码: sumbit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if(checkNoAttndance.isChecked

我试图从地图集中删除所有元素,但我得到ConcurrentModificationException,所以我有一些复选框,它们的值在地图集中,但我想在按下submit按钮时删除所有地图集值

我的代码:

 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();
}