-2

This question can be stated in two parts:

  1. Is 5000 items too much for a scroll view to handle? (In the memory waste aspect of it, most of the list will not be visible at a given time)

  2. Is there a recommended way to handle just a partial list and prepend/append more items as the user scrolls up and down? (Preferably in a transparent way, so the user has a smooth scrolling experience)

I tried to do it by adding my own onScrollListener, the problem I found is that as if I change the scroll view contents I need to scroll it to mantain the visible list on the same item position.
Why? Because if the current y scroll position is 445 on item number 19, and I add one item on the top, item 19 will now be in y scroll position 478.
So I should scroll to position 478 to keep the same view for the user. And all this makes the scrolling NOT smooth.

Some more explanation: I try to show a two dimensional table, not unlike a spreadsheet. And the table is dynamically populated and the width of each column in the table may change as a result of new data.

ilomambo
  • 8,290
  • 12
  • 57
  • 106
  • http://stackoverflow.com/questions/1080811/android-endless-list – maffo Feb 03 '13 at 15:38
  • @PoiXen, The link you provided answers a different question. I am not seeking to expand the list as the user reaches the end (which is the solution in your link) I want to have a list of constant size, so If I append 50 items I also remove 50 items from the top. – ilomambo Feb 03 '13 at 15:43
  • @ilomambo How is your problem different than what is answered here: http://stackoverflow.com/questions/11684520/efficient-listview-in-android – Morrison Chang Feb 03 '13 at 16:58
  • Do you have to use scrollview? Why not use ListView w/ an Adapter? ListView basically solves question #2. And somewhat solves question #1. – Nathan Feb 03 '13 at 17:07
  • @MorrisonChang Good link!,I learned a lot about ListViews. It might be good for me. I'm adding some more explanation about this in the question body. – ilomambo Feb 04 '13 at 18:22
  • @Nathan From the links Morrison Chang gave in his comment, it seems listView is intended to solve both #1 and #2. I will give it a try. – ilomambo Feb 04 '13 at 18:27
  • Morrison or/and Nathan: If you submit your comment as an answer I can mark it as answered. – ilomambo Feb 04 '13 at 18:29

1 Answers1

1

You may just want to start by understanding ListViews.

See this SO question: Efficient ListView in android

Alternatively if you want to do some type of spreadsheet like view you may want to take a look at this project:

https://github.com/jess-anders/two-way-gridview

I haven't tried it but it appears to address some of your concerns.

Community
  • 1
  • 1
Morrison Chang
  • 11,691
  • 3
  • 41
  • 77