微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

嵌套的RecyclerView展开/折叠功能未响应

如何解决嵌套的RecyclerView展开/折叠功能未响应

我里面有2个RecyclerView(垂直)。 RecyclerView的外部具有子项列表,而在此Inner内,RecyclerView具有特定子项可用的设备列表。 内部RecyclerView有一个条件,即它应该第一次显示2个项目,并且这些对象在此按钮上都有一个按钮,单击该内部RecyclerView的整个列表对于特定的位置(子代)将可见。 我已经轻松实现了上述方案,但遇到了2个问题:

  1. 在“外部回收站视图”项目中单击-仅扩展最后一个位置的项目,单击其他位置则保持折叠状态。
  2. 滚动后,展开的视图会自动折叠。

下面我分享了我的代码

  1. 将完整的子级列表发送到外部适配器。

    adapterHomeChildList.setList(responseChildList); //将列表发送到适配器。

2。设置列表功能和外部适配器的BindViewHolder

public void setList(List<UserWithDeviceListResponse> mChildLists) {
    childLists = new ArrayList<>();
    childLists = mChildLists;

    notifyDataSetChanged();
}

onBindViewHolder(....)

AdapterHomeDeviceList adapterHomeDeviceList = new AdapterHomeDeviceList(context);
    adapterHomeChildListBinding.setAdapter(adapterHomeDeviceList); // set inner device list adapter

    if (childLists.get(position).getDeviceList() != null && !childLists.get(position).getDeviceList().isEmpty()) {
        if (childLists.get(position).isExpanded()) {
            adapterHomeChildListBinding.setIsSeeMore(false);  // set see more button visibility
            adapterHomeDeviceList.setList(childLists.get(position).getDeviceList());
        } else {
            if (childLists.get(position).getDeviceList().size() > 2) {
                adapterHomeChildListBinding.setIsSeeMore(true);
                filter(childLists.get(position).getDeviceList(),adapterHomeDeviceList); // show top 2 item only
            } else {
                adapterHomeDeviceList.setList(childLists.get(position).getDeviceList());
            }
        }
    }
  1. 项目点击界面句柄

    private void setRecyclerViewExpanding(int position){ for(int i = 0; i

搜索了很多与此相关的问题,但是大多数答案都使用可扩展列表视图,但我没有使用可扩展视图。 请帮帮我。 任何帮助将不胜感激。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。