我有两个ArrayLists,我想要引用第二个ArrayList来删除第一个ArrayList的所有对象。我知道我可以使用removeAll()方法,但它返回false.Both ArrayLists是相同的类型。 removeAll()
的任何替代方案 @Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
if (successfullyAssigned) {
ArrayList<CustomDataModel> dataList = adapter.getDataSet();
Boolean deleted = dataList.removeAll(taskDataList);
Log.d("LogTag", "deleted ? " + deleted);
setPreference(getPrefName(), dataList);
}
}
public ArrayList<CustomDataModel> getDataSet() {
return dataSet;
}
private class AssignTask extends AsyncTask<ArrayList<CustomDataModel>, Void, Void> {
ProgressDialog progressDialog;
ArrayList<CustomDataModel> taskDataList;
Boolean successfullyAssigned;
@SafeVarargs
@Override
protected final Void doInBackground(ArrayList<CustomDataModel>... callData) {
taskDataList = callData[0];
答案 0 :(得分:1)
这有三个原因可以发生
CustomDataModel.equals()
。