我正在使用recyclerview。我想将多选添加到我的列表中。第一次点击应该是在该正常点击之后的长时间点击。长按可以正常工作,但单击不起作用。单击功能起作用,但是所选列表未添加到列表中。需要帮忙。提前致谢。 下面的代码用于长按
clickSupport.setOnItemLongClickListener((recyclerView, position, v) -> {
Log.e("CLF","longClick");//M
selectedCallLogs = new ArrayList<>();
selectedCallLogsSocketId= new ArrayList<>();
selectedCallLogs.add(callLogsList.get(position));
callLogsAdapter.setSelectedLogs(selectedCallLogs);
refreshAdapter();
if(!selectedCallLogs.isEmpty())
callLogDeleteListener.onCallLogSelected(selectedCallLogs, selectedCallLogs.size());
return true;
});
setCallLogsInfo();
下面的代码用于短按
clickSupport.setOnItemClickListener((recyclerView, i, view1) -> {
if (selectedCallLogs.isEmpty()){
}
else{
CallLogs selectedLogss = callLogsList.get(i);
if (selectedCallLogs.contains(selectedLogss)){
selectedCallLogs.remove(selectedLogss);
}
else{
selectedCallLogs.add(selectedLogss);
}
callLogDeleteListener.onCallLogSelected(selectedCallLogs,selectedCallLogs.size());
callLogsAdapter.setSelectedLogs(selectedCallLogs);
refreshAdapter();
}
在“多项选择”之后,我要删除这些列表。