user2436032
user2436032

Reputation: 365

Can we set the number of items in ListView that it should keep in memory, such that the ListView won't recycle every time

I have a listView, with some very heavy items (Non scrollable GridView, and some TextView). I have implemented the ViewHolder pattern in the adapter but still the scrolling is not smooth. Can we specify in the ListView, as to how many items it should keep in memory. I have only 3 items in the listView but on scrolling , it always have some discontinuity when a new item come into view.

Example: Initially 1st child and some portion of 2nd clild is visible, then user scroll, when he is about to hit the 3rd item, there is a slight discontinuity and then 3rd item appear. On scrolling up, the same thing happens when 1st child is about to enter the screen again.

Can we somehow specify that the listView should keep 3 items in memory and dont recycle them, like we do in case of ViewPager(using setOffscreenPageLimit). I know there is no built in support to specify that, but can we extend listView somehow to have such functionality.

Upvotes: 1

Views: 242

Answers (1)

Elltz
Elltz

Reputation: 10859

To answer your question is

NO

Do this, set or Views VISIBILTY to GONE and use the postion in getView() parameter to to know if its the first item or not. Then set the required Views for that particular position to VISIBLE and all other Views to GONE

Does it seem helpful to you?

Upvotes: 1

Related Questions