简体   繁体   English

在列表视图中,Android中可以加载多少个列表项

[英]In List view how many list items can load in android

Normally in ListView are used in android,but how many items can totally load in list view ? 通常在Android中使用ListView,但是在列表视图中可以完全加载多少个项目? Is it possible to load more than 10,000 items ? 是否可以装载10,000多个物品?

ListView itself will keep only a handful of view items in memory - those that are displayed on screen and possibly a few scrap items that are waiting to get recycled. ListView本身将在内存中仅保留少数视图项-屏幕上显示的视图项,以及可能等待回收的少量废品。 ListView is not the limiting factor. ListView不是限制因素。

What is a limiting factor is the Adapter that feeds the ListView . 限制因素是提供ListViewAdapter If your adapter implementation keeps all data items in memory (eg an ArrayAdapter ), then you're bound to hit a limit at some point. 如果您的适配器实现将所有数据项保留在内存中(例如ArrayAdapter ),那么您势必会达到极限。 There are other adapters such as CursorAdapter s that load the data items on demand and don't keep everything in memory. 还有其他适配器,例如CursorAdapter ,可以按需加载数据项,而不将所有内容保留在内存中。 They scale further. 他们进一步扩大规模。

Of course there's usability. 当然有可用性。 ListView is practically unusable for browsing through a list of 10000 items. ListView实际上无法用于浏览10000个项目的列表。 If you really have that much data to display, you have an user interface design problem. 如果确实要显示那么多数据,那么您将遇到用户界面设计问题。

Try to use ViewHolder and convertView in View getView(int position, View convertView, ViewGroup parent) . 尝试在View getView(int position, View convertView, ViewGroup parent)使用ViewHolderconvertView You can load more than 10,000 items with low memory usage. 您可以在内存不足的情况下加载10,000多个项目。

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

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