简体   繁体   English

Android:Recyclerview 适配器内的 Recyclerview 适配器。 如何更新 recylcerview 内部的数据?

[英]Android: Recyclerview adapter inside recyclerview adapter. How to update data of inside recylcerview?

I got a recylcerview, which has another recylcerview as an element of it.我有一个 recylcerview,它有另一个 recylcerview 作为它的一个元素。 However, i am confused how to update data of the inside recylcerview.但是,我很困惑如何更新内部 recylcerview 的数据。 How should I do it?我该怎么做?

I don't know if this will work for you because i don't have your code, but you can create a updateAdapter , inside of it you must refresh everything.我不知道这是否适合您,因为我没有您的代码,但是您可以创建一个updateAdapter ,在其中您必须刷新所有内容。

For example we have 2 arrayList:例如我们有 2 个 arrayList:

private void updateAdapter() {
    this.mItems = c.getArray();
    this.mItemsNr = c.getNr();

    //and call notifyDataSetChanged
    notifyDataSetChanged();
}

mItems and MItemsNr are 2 arrayList and c is an object where i have the 2 new arrayList .So i update the 2 arrayList and hten i call notifyDataSetChenged(); mItemsMItemsNr是 2 个 arrayList 并且c是一个对象,其中我有 2 个新的arrayList 。所以我更新了 2 个arrayList和 hten 我调用了notifyDataSetChenged(); to update my adapter.更新我的适配器。

Hope this could help you.希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM