VerticalGridFragment Endless scroll

2k views Asked by At

I'm creating android tv app but I don't know how to implement endless scroll in Verticalgridfragment, i use ArrayObjectAdapter, can someone help me do that?

1

There are 1 answers

1
Kyle Venn On BEST ANSWER

I'd love to give you a full answer with oodles of code samples but I'm not at my work computer. Basically you'll implement the onItemSelected listener in your Browse/RowsFragment (it should be something like setOnItemViewSelectedListener() from your fragment).

Then you do a check to see if the currently selected element is within 5 or 10 or 15 elements from the end of the list. If it's within that threshold, then make the request for the next page of your list and call addAll() on your adapter when you get the next page. You can optionally show a "loading card" while the next page request is in flight and remove it when you get your data.

I based my implementation off of this open source project - while it's not perfect it should be enough of a code sample to get your started.