在这里,我想取消选择使用时代广场库选择的范围的日期。我通过以下方式选择范围:
if (selectionMode == SelectionMode.RANGE && selectedCells.size() > 1) {
// Select all days in between start and end.
Date start = selectedCells.get(0).getDate();
Date end = selectedCells.get(1).getDate();
selectedCells.get(0).setRangeState(MonthCellDescriptor.RangeState.FIRST);
selectedCells.get(1).setRangeState(MonthCellDescriptor.RangeState.LAST);
Log.d("First", MonthCellDescriptor.RangeState.FIRST +"");
Log.d("Last",MonthCellDescriptor.RangeState.LAST+"");
for (List<List<MonthCellDescriptor>> month : cells) {
for (List<MonthCellDescriptor> week : month) {
for (MonthCellDescriptor singleCell : week) {
if (singleCell.getDate().after(start)
&& singleCell.getDate().before(end)
&& singleCell.isSelectable()) {
singleCell.setSelected(true);
singleCell.setRangeState(MonthCellDescriptor.RangeState.MIDDLE);
selectedCells.add(singleCell);
}
}
}
}
}
当我尝试删除选定的日期范围时,它也会删除其他日期:
if (selectedCell.getDate().equals(date)) {
// De-select the currently-selected cell.
selectedCell.setSelected(false);
selectedCells.remove(selectedCell);
date = null;
break;
}
示例: 如果选择的范围是 10 到 30,则在点击 22 时,应从该范围中取消选择 22。