user291701
user291701

Reputation: 39721

ViewPager + recycling views?

I'd like to create a gallery of photos that swipe left and right. At first I took a look at Gallery, but it's marked as deprecated.

http://developer.android.com/reference/android/widget/Gallery.html

We're told to try ViewPager instead. But the PagerAdapter class doesn't handle recycling of views for us (like a standard ListView), does it?

http://developer.android.com/reference/android/support/v4/view/PagerAdapter.html

Is it up to us to build the recycling mechanism?

Thanks

Upvotes: 5

Views: 7899

Answers (3)

Ali
Ali

Reputation: 31

This HorizontalListView is great, i used it to do exactly what you want.

Upvotes: 2

FoamyGuy
FoamyGuy

Reputation: 46856

see the link in the edit on this question The link in the Edit, and the answers give you some possible ways to solve.

There is also a HorizontalListView online somewhere if you search for it that makes a fine replacement for Gallery and does recycle its views.

Upvotes: 1

josephus
josephus

Reputation: 8304

But the PagerAdapter class doesn't handle recycling of views for us (like a standard ListView), does it?

No, and I think it's because it was built assuming you are using different layouts for each of the page.

Also, as it is not being scrolled as fast as a ListView (you cannot "fling" a ViewPager to skip multiple pages), I think it doesn't need to have to recycle.

Upvotes: 3

Related Questions