ListView与自定义ListDataAdapter请求项两次 [英] ListView with custom ListDataAdapter requests items twice

查看:61
本文介绍了ListView与自定义ListDataAdapter请求项两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过创建一个派生自VirtualizedDataSource的类来实现IListDataAdapter,但是当ListView使用它时我看到了一些奇怪的行为。

I've implemented IListDataAdapter by creating a class derived from VirtualizedDataSource, but I'm seeing some odd behaviour when it's used by the ListView.

向右滑动时,  ; itemsFromIndex按预期重复调用以在数据中进行分页。当我一直向右滑动时,它会从一开始就再次请求所有项目!我可以缓存项目以保存再次获取它们,但是有一些
的方法来改变ListView的行为,所以它不会两次请求项目吗?如果我再次开始向左滚动,我会理解是否请求了这些项目,但我不了解当前的行为。

When swiping right, itemsFromIndex is called repeatedly as expected to page in the data. When I swipe all the way to the right, it then requests all the items again from the start! I could cache the items to save fetching them again, but is there some way to change the behaviour of the ListView so it doesn't request the items twice? I would understand if it requested the items if I started scrolling left again, but I don't understand the current behaviour.

推荐答案

当然,如果您有大量数据,这才真正重要吗? 对于少量数据,这是微不足道的。 默认情况下,一旦Listview达到项目阈值,它就会开始以预定义的数据页面大小获取数据。 您可以通过
更好地控制获取的内容以及何时需要。 我实际上刚刚回答了一个与listview如何逐步获取数据有关的问题:

Of course this would only really matter if you had a lot of data correct?  For small amounts of data this is trivial.  By default once Listview hits a threshold of items it would start fetching data in a pre-defined data page size.  You can have a finer control of what gets fetched and when if you would like.  I actually just answered a question related to how listview fetches data incrementally here:

http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/a82b6d34-e1d6-4d7d-a7cd-da69e6fbc3f2


这篇关于ListView与自定义ListDataAdapter请求项两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆