Android 向ExpandableRecyclerAdapter添加新的父对象

Android 向ExpandableRecyclerAdapter添加新的父对象,android,generics,android-recyclerview,expandablerecyclerview,Android,Generics,Android Recyclerview,Expandablerecyclerview,我在我的项目中使用了一个嵌套的RecyclerView。它工作得很好,除非您需要动态更新父列表 我的项目将产品类作为父对象(并扩展了父列表项)。我正在从API获取产品列表,因此需要清除当前列表并添加我已获得的列表 在ExpandableRecyclerAdapter中,我尝试了这种方法- public void onDataChanged(ArrayList<Product> parentObjects) { this.getParentItemList().clear();

我在我的项目中使用了一个嵌套的RecyclerView。它工作得很好,除非您需要动态更新父列表

我的项目将
产品
类作为父对象(并扩展了
父列表项
)。我正在从API获取产品列表,因此需要清除当前列表并添加我已获得的列表

在ExpandableRecyclerAdapter中,我尝试了这种方法-

public void onDataChanged(ArrayList<Product> parentObjects) {
    this.getParentItemList().clear();
    this.getParentItemList().addAll(parentObjects);

    this.notifyItemRangeChanged(0, parentObjects.size() - 1);
}
public void onDataChanged(ArrayList parentObjects){
这个.getParentItemList().clear();
this.getParentItemList().addAll(parentObjects);
此.notifyItemRange已更改(0,parentObjects.size()-1);
}
然而,它给出了一个奇怪的通用错误

Error:(60, 33) error: no suitable method found for addAll(ArrayList<Product>)
method List.addAll(Collection<? extends CAP#1>) is not applicable
(actual argument ArrayList<Product> cannot be converted to Collection<? extends CAP#1> by method invocation conversion)
method List.addAll(int,Collection<? extends CAP#1>) is not applicable
(actual and formal argument lists differ in length)
method Collection.addAll(Collection<? extends CAP#1>) is not applicable
(actual argument ArrayList<Product> cannot be converted to Collection<? extends CAP#1> by method invocation conversion)
where CAP#1 is a fresh type-variable:
CAP#1 extends ParentListItem from capture of ? extends ParentListItem
错误:(60,33)错误:找不到适用于addAll(ArrayList)的方法

方法列表。添加所有(收集)我也面临着完全相同的问题。你对上述问题有什么解决方案吗?我也有这个问题。似乎答案可能在这里: