Reputation: 1289
While maintaining the current position in the ListView?
I'm trying to create a sort of "calendar-like" ListView that starts on the current month, and allows the user to scroll upward back in time, one month at a time, infinitely.
I've found setStackFromBottom() method in ListAdapter, but that still creates the views with indices (positions) from top to bottom.
I think I need to find a way to either create a ListAdapter that uses some sort of a queue rather than position indexes, or a ListAdapter that starts with the position at the bottom and works it's way upward.
Thanks ahead for any assistance!
Upvotes: 1
Views: 2463
Reputation: 4199
If you have a listadapter you probably have a java collection for holding the underlying data. In this collection (lets say it's a list) you can insert new stuff using add(int position, object data)
so you just have to call notifyDataSetChanged()
( http://developer.android.com/reference/android/widget/ArrayAdapter.html#notifyDataSetChanged) in your adapter and everything should work fine.
Upvotes: 3