0

I was playing with the gmail app today for the first time in ages and really enjoyed the design of the ListView and how it works.

I noticed that the email previews are loaded as you scroll to the bottom of the list. This is not a conventional cursor adapter as far as I can see.

I am in a similar situation where I may have a list from 0-1000+ messages in a list. In the past I thought the cursor adapter would handle all of this nicely, but having seen the way gmail is doing it, it makes me think I might need to re-write my ListView.

My listview draws its data from an sqlite db, which for my project might mean my cursor is fine. Gmail probably downloads emails on the fly and stores them, hence the gmail app's list view is designed for this in mind.

Anyway, I would appreciate some insight.

HGPB
  • 4,346
  • 8
  • 50
  • 86

2 Answers2

1

You talk about so called "endless list", when more data is shown on the list on demand, once user scroll to it. It is irrelevant what is your data source - it's list pattern and will work fine with any dataset, be it ordinary array or DB. There are ready-to-use implementations you may want to try at first, like https://github.com/commonsguy/cwac-endless

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • The Datasource shouldn't be irrelevant. If I am dowloading form the internet, there is a noticable delay for which the user is informed. However, a cursor adapter is much faster as it is obviously drawing its results straight form the device. – HGPB Jul 08 '13 at 09:45
  • If you do not have further data, then you show kind of "busy" indicator to the user, download missing data and update the list. if the data is already here you show it instantly. So it is irrelevant where data is coming from. – Marcin Orlowski Jul 08 '13 at 09:48
  • Since my data is on the device, is a cursor adapter implementation satisfactory for large amounts of data? Or will the cursor adapter's performance degrade with large amounts of data? – HGPB Jul 08 '13 at 09:49
  • depends on what "large amounts" really means. I think that it should be fine anyway – Marcin Orlowski Jul 08 '13 at 09:50
  • All right, since I am NOT sourcing any data online my cursor adapter should be able to cope with 1000's of list items without getting tired...? Which also means no loading pattern would be necessary. – HGPB Jul 08 '13 at 09:52
  • Yes, it should, if you got 1000's of rows, then you got different problem -> usability. You may want to group your rows somehow otherwise users will not enjoy browsing the list. – Marcin Orlowski Jul 08 '13 at 09:56
0

Try this

@Override
public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {
if(firstVisibleItem + visibleItemCount >= (totalItemCount-2) && connection.hasDataConnectivity()) {

       // fetch some more data

        }
}
M-Wajeeh
  • 17,204
  • 10
  • 66
  • 103
OMAK
  • 1,031
  • 9
  • 25