开发者

Android: Prepending items to a ListView with TranscriptMode set to Normal

开发者 https://www.devze.com 2023-04-10 18:12 出处:网络
In my app, I have a ListView with TranscriptMode set to Normal, so when items get added, they appear at the bottom of the list and the list scrolls from the bottom upward. I am using my list such that

In my app, I have a ListView with TranscriptMode set to Normal, so when items get added, they appear at the bottom of the list and the list scrolls from the bottom upward. I am using my list such that when the user scrolls the list downward, meaning that they want to 开发者_开发知识库go to the top of the list, as soon as I reach the first item in the list, I want to load more items and prepend them into the list, meaning that they appear before the first item, so that the user can keep scrolling until they reach the very first item.

I have not been successful at this. As soon as I prepend items and refresh the adapter with notifyDataSetChanged, the ListView adapter requests the very first item in my list. What I want it to do is request the item that preceded the first item before I prepended my new items. As a result, my ListView starts with the first item making it look like it skipped all the items from the last scrolled item.

Is there a way to get the ListView to keep on scrolling and request the items in the order they appear in the list?

0

精彩评论

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