将列表适配器转换为回收器视图.适配器失败



我有一个RecyclerView.Adapter类,我想将其转换为ListAdapter但它返回一个错误:"无法投射"。

public void setAdapter()
{
    RecyclerAdapter adapter = new RecyclerAdapter(context);
    ListView.setAdapter((ListAdapter) adapter);
}

RecyclerView.Adapter直接extends Object

因此,您会收到该错误。此外,我认为无论如何您都不能在ListView中使用RecyclerView适配器。

最新更新