0

If i use SetListAdapter to show +10,000 rows, may problems occur?

If yes, please guide me for choose a better way to show these rows.

Thanks

keyser
  • 18,829
  • 16
  • 59
  • 101
odr_m9611
  • 195
  • 3
  • 16
  • Yes, problems might occur. Why would you want the user to see that? – keyser Aug 08 '13 at 10:58
  • Problems can always occur, can you be more specific please? – Eric Tobias Aug 08 '13 at 10:59
  • 1
    10,000 rows will cause problems with _any_ adapter. You should never use that much data on one screen. A much better solution would be to show only a few rows (20-30-whatever) with a "show more" option. – Aleks G Aug 08 '13 at 10:59
  • This is for a sms collection application,i'm a newbie ,sorry if ask a very regular question – odr_m9611 Aug 08 '13 at 11:00
  • @user2273788 have u ever seen any application on play-store which has 10,000 items in list? – TheFlash Aug 08 '13 at 11:01
  • The point of the adapter in a list view is that only the visible views will be loaded at once, so assuming the dataset is also loaded sequentially then there will be no problem. – FunkTheMonk Aug 08 '13 at 11:03
  • 1
    @ Pratik, no, but i haven't any experience in android programming,please guide me if possible – odr_m9611 Aug 08 '13 at 11:04
  • @user2273788 as u have mentioned it is for sms collection application i can give u some idea...u can fetch items as per the dates or say duration (last month,from date1 to date2,last week and so on)...and just display that many rows..it will be beneficial...if u want to check how this type of apps being managed then check "SMS Addict" application on play. – TheFlash Aug 08 '13 at 11:10

1 Answers1

1

ListView can display any number of elements data; but there is a trick when we're discussing about large and very large numbers: you need to re-use the views that the ListView is holding. This Google IO presentation is the best thing I can recommend you.

Now, there are other things I can think of that will have a negative impact:

  1. How much memory do those 10k object take? If it's an SMS collection, then 10k * 160 max chars per message * 4 bytes per char would give 6.4 million bytes which is ~6 Mb. Now 6 MB is not really that much to hold in memory but it's not a number you can neglect.
  2. How fast accessible is an object in this store? If you hold this data structure in memory and you would store it as an ArrayList then I believe you would have instant access. Or decide for yourself what data structure to use. Seems to me choosing the right collection is really important. Maybe this article will help you.

In the end you should also consider about how users will use the app. Would it worth storing all messages in memory since the user will probably want to see latest ones, the ones from last week, or the ones from his favorite contacts? Maybe a filtering option would be helpful to have and this way you could persist them in SQLite.

gunar
  • 14,660
  • 7
  • 56
  • 87
  • Thank you very much .Is it possible to load the rows gradually? for example,30 rows loaded,and when user arrived to the end of 30 rows ,then next 30 rows load – odr_m9611 Aug 08 '13 at 11:38
  • 1
    Try this article (http://www.androidhive.info/2012/03/android-listview-with-load-more-button/) or use some sort of 3 party swipeable listview (https://github.com/47deg/android-swipelistview or http://stackoverflow.com/questions/15367671/android-listview-swipe-to-delete-like-in-gmail-app) – gunar Aug 08 '13 at 12:03