开发者

Android Scrolling Autogrow ListView

开发者 https://www.devze.com 2023-03-02 22:34 出处:网络
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/

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号