大的ListView在Android中ListView、Android

2023-09-07 10:49:05 作者:耗尽温柔

建立一个字典应用程序,我需要一个的ListView 显示超过10万项。我想,让用户滚动尽可能多的需要。

Building a dictionary application I need a ListView that shows over 100k items. I want to let the user scroll as much as needed.

什么是搜索和显示词的最佳实践? 它是确定以显示在ListView(用于pereformance)15万字? 如果不是如何在用户到达列表的末尾添加100换言之?

What's the best practice for searching and showing words? Is it ok to show 150,000 words in the ListView (for pereformance)? If not how to add 100 other words after the user reaches to the end of the list?

目前我显示50个字previous和50字搜索词的下一个。

Currently I show 50 words previous and 50 words next of searched word.

感谢你。

推荐答案

(响应澄清业绩第二个答案)的

有不同的方法的基础上,你的数据是做到这一点。

There are different ways to do this based on where your data is.

最好的办法是在SQLite数据库中的数据,并使用的CursorAdapter 。安卓然后管理您的数据读取,也不会获取当前没有被显示在屏幕上的数据。

The best way is to have your data in a sqlite database and use a CursorAdapter. Android then manages the fetching of your data and won't fetch data that isn't currently being shown on the screen.

如果你的话是在内存中的数组,尝试 ArrayAdapter 或SimpleAdapter.

If your words are in an array in memory, try ArrayAdapter or SimpleAdapter.

的适配器接口,使所有的上述的类继承的,被设计无论对象列表中的数目,以提供良好的ListView性能

The Adapter interface, from which all of the above classes inherit, is designed to provide good ListView performance regardless of the number of objects in the list.

 
精彩推荐
图片推荐