简体   繁体   English

如何从回收视图中停止回收视图

[英]How to stop recycler view from recycling views

I have a nested recycler view, which basically looks like a card view and a check list inside the card view, Now the issue i am facing is that when i close my app and reopen it.It starts displaying the list which is in the first card View to every other Card View inside my recycler View, to stop this i have used setIsRecyclable(false) inside my child adapter, but it isn't working and i keep facing the issue.我有一个嵌套的回收器视图,它基本上看起来像一个卡片视图和卡片视图内的一个检查列表,现在我面临的问题是当我关闭我的应用程序并重新打开它时。它开始显示第一个列表卡片视图到我的回收站视图中的所有其他卡片视图,为了阻止这种情况,我在我的子适配器中使用了 setIsRecyclable(false),但它不起作用,我一直面临这个问题。 How can i change my implementation?我怎样才能改变我的实施? I am using an observer to update my child adapter.我正在使用观察者来更新我的子适配器。

Code Inside my OnBindViewHolder for child adapter子适配器的 OnBindViewHolder 中的代码

    holder.setIsRecyclable(false)

    holder.itemView.check_box_completed.isChecked = getItem(position).completed
    holder.itemView.text_view_name.text = getItem(position).name
    holder.itemView.text_view_name.paint.isStrikeThruText = getItem(position).completed

    Log.d("TAG1", "Inside: ${getItem(position)}")





    holder.itemView.check_box_completed.setOnCheckedChangeListener { checkBox, isChecked ->

  if (isChecked) {


            mainViewModel.updateListItem(
                TaskList(
                    getItem(position).name,
                    isChecked,
                    getItem(position).Taskid,
                    getItem(position).taskNoteId
                )
            )

        } else {

            mainViewModel.updateListItem(
                TaskList(
                    getItem(position).name,
                    isChecked,
                    getItem(position).Taskid,
                    getItem(position).taskNoteId
                )
            )

        }
    }

Please do not spend time on stopping recycler view from recycling views.请不要花时间从回收视图中停止回收者视图。
Instead, I would request you to change your design.相反,我会要求你改变你的设计。

Recycler View itself is a big functionality and should be managed separately from other views. Recycler View本身是一个很大的功能,应该与其他视图分开管理。
By that I mean is, please do not nest Recycler View deep inside other views.我的意思是,请不要将 Recycler View 嵌套在其他视图的深处。

Try too keep the design simple of your app.尽量保持应用程序的设计简单。 This will be easy for you as a developer to maintain the code and also add new features in future.作为开发人员,这将很容易维护代码并在将来添加新功能。

I understand that you need to have Card Views in your UI, however, please try to see if you can move the 'Card View' to separate fragment/activity.我了解您的 UI 中需要有Card Views ,但是,请尝试查看是否可以将“卡片视图”移动到单独的片段/活动中。 Adding an extra screen to reduce complexity in design is always acceptable.添加额外的屏幕以降低设计的复杂性总是可以接受的。

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

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