Skip to content Skip to sidebar Skip to footer

Load Data When Scrolling To Listview

I want to load data when user scroll . The loaded data is combine at the end of the ListView. I test this feature . I found endless scroll in android .But I use this when the user

Solution 1:

For example, you could use this code within your getView method:

@Overridepublic View getView(finalint position, View row, final ViewGroup parent) {

...
  if (position > lastViewed && position == getCount()-1) {
      lastViewed = position;
      runTask(); //I immagine an AsyncTask which fetch data from the net or from a local  db
  }
...
}

Of course in your hypothetical AsyncTask you do not have to clear the adapter on onPreExecute but just adding the new items.

Sorry but the question is a bit too generic, without knowing the stucture of your code it comes complicated to answer, anyway I hope it will help.

Post a Comment for "Load Data When Scrolling To Listview"