如何从适配器中仅获取新项目?

发布于 2024-11-15 18:05:36 字数 227 浏览 2 评论 0原文

我有一些列表,并且创建适配器

Add adapter = new Add(this,R.layout.vieww,cursor, items);

现在,当我更改项目列表时,afren notifyDataSetChanged(),我得到了视图中反映的更改,到目前为止一切顺利...但我需要的是仅获取新项目,仅获取已更改的项目

我该怎么做?

I have some list and that I create adapter

Add adapter = new Add(this,R.layout.vieww, cursor, items);

Now when I change the items list, afren notifyDataSetChanged(), i get the reflected changes in the view, so far so good... But the thing I need is to get only the new item , only the items that have been change

How can I do this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋日私语 2024-11-22 18:05:36

好吧,只需从 items 数组中删除旧项目,这将是最简单的事情。

您还可以按新项目对数组进行排序,并更改适配器计数以仅返回新项目的计数。

但我不知道为什么会有这样的解决方案。即使存储您不展示的物品也是不实际的。如果您需要它们,您还可以拥有 2 个数组(一个新项目数组和一个旧项目数组)。对于旧的列表,您可以在更改列表之前添加所有项目,然后只需向仅包含新项目的适配器添加一个新数组。

well just remove the old items from the items array which would be the simplest thing to do.

you can also sort the array by new items and change the adapter count to return just the count for new items.

but i don't know why a solution like that. it isn't really practical to even store items that you don't show. if you need them you can also have 2 arrays ( a new item array and an old item array). to the old one you can add all the items before you change the list and then just add a new array to the adapter containing only the new items.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文