Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Naomi Touchet11,300 Points
How can I implement an infinitely scrolling list of items in my Android app?
I'm creating an app which will let people read through 1,000 different answers to commonly asked questions. I want them to be able to read through all of the answers (I was thinking it would work best to implement some sort of infinitely scrolling list) as well as to be able to read through the answers by category. Does anyone know the best way to do this? I would also appreciate if anyone knows any good resources to direct me towards.
I'm also wondering if I should use a database or if I should just use an array. (Right now I have it set up as an array, but I've only put in a couple of the answers. I'm not sure if an array will work once I have all 1,000 answers entered.)
Ben JakubenTreehouse Teacher
For the ListView itself, I'd recommend looking at a 3rd party library so you don't have to reinvent the wheel about making an infinite ListView. Check out this one, for example: https://github.com/weixiao1984/Android-Infinite-Scroll-Listview
As for your data, it sounds like a database might be appropriate for your answers. Our Data Persistence course is almost ready and should be able to help you. But an array might actually be just fine. There's no need to over-complicate it if an array is good enough for your purposes. An array of 1000 items just depends on the type of item being stored. The more complex the data object, the more memory it will take up.