Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Large ListView in Android

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

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?

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

Thank you.

like image 288
Heidar Avatar asked Feb 24 '11 16:02

Heidar


People also ask

Is ListView deprecated Android?

ListView Class (Android. Widget) | Microsoft Learn. This browser is no longer supported.

What is a ListView in android?

Android ListView is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.

What is ListView adapter in android?

BaseAdapter with Android ListView. ListView is a ViewGroup that displays a list of vertically scrollable items. The list items are automatically inserted into the list using an adapter that is connected to a source, such as an array or a database query, and each item is converted into a row in the ListView.


1 Answers

(second answer in response to clarification about performance)

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

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.

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

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.

like image 102
Matthew Willis Avatar answered Sep 30 '22 18:09

Matthew Willis