Ian
Ian

Reputation: 1

Android Scrolling Autogrow ListView

Hello I am trying to build a listview based on content from the web. I have had a look at :

http://androidboss.com/load-listview-in-background-asynctask/

example but it uses a predefined array of months. How can I substitute the known array of months for an unknown undetermined number of items from the internet? I want to load a listview with some data from the internet, the user scrolls the list and it retrieves the next row(s) from the internet etc etc rather than using a array of predetermined length. Thanks Ian

Upvotes: 0

Views: 620

Answers (2)

Trevor
Trevor

Reputation: 10993

It sounds like you need to extend an adapter such as ArrayAdapter. Extending an ArrayAdapter so that you can dynamically generate the rows or alter the number of rows, and also notify the Adapter that the underlying data has changed, is a very common exercise in Android.

You'll find quite a few tutorials on this but, very basically, if you implement your own adapter by extending ArrayAdapter you can override getView() to programmatically generate each view, and you can override getCount() to provide the number of rows. You can use notifyDataSetChanged() to trigger a refresh of the list on the screen if some data has changed and you need to refresh.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006869

You can use my EndlessAdapter for that. The project has a demo/ subproject demonstrating its use.

Upvotes: 2

Related Questions