简体   繁体   English

保存recyclerview列表的状态

[英]Save state of recyclerview list

I created a list using recyclerview in one activity. 我在一个活动中使用recyclerview创建了一个列表。 The user dynamically removes some of the items he/she doesn't from the list so the problem arises when he navigates back to that activity. 用户动态地从列表中删除了一些他/她没有的项目,因此当他导航回该活动时就会出现问题。 The activity retrieves all the data items,including the ones he removed. 该活动将检索所有数据项,包括他删除的数据项。 How do i make sure the recyclerview list retains the state the user left it in? 我如何确保recyclerview列表保留用户留下的状态?

The problem is in List you are using. 问题出在您正在使用的列表中。 You need to use Activity's list reference in Adapter too, Don't create different list in adapter just save Activity's list reference in Adapter. 您还需要在Adapter中使用Activity的列表引用,不要在适配器中创建其他列表,只需将Activity的列表引用保存在Adapter中即可。

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

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