0

This problem has ben bugging me for longer than I am willing to admit, so I came here for help.

I am, AFAIK, restrained to using a FragmentStatePagerAdapter to display my fragments due to bitmaps and OOMs on Android.

I am implementing a game, and I have a set of fragments. Some of these fragments can be locked, and should thus not be shown when swiping through the list.

For instance:

I have a set containing 1..10 fragments. In this set, fragment #5,#6 and #7 are locked. This means I have two subsets (1..4 and 8..10) of unlocked fragments.

The functionality I'd like to have, is to swipe from #1 to #4 and to swipe from #8 to #10.

It should not be able to swipe from #4 to #5, and it should not be possible to swipe between the two subsets.

When displaying fragment #4, it should function as if #4 was the end of the list. Accordingly, when displaying #8, it should appear as #8 is at the start of the list when being in the other subset.

Is there any suggestions? I have tried to override the getItem and passing in subsets, which has mainly resulted in either NPEs or displaying wrong fragments.

larsba
  • 51
  • 5
  • And how are fragments 5,6 and 7 being shown? – user Apr 06 '14 at 12:04
  • Fragments 5,6 and 7 should not be shown at all. They are locked, and can be unlocked by purchase etc... – larsba Apr 06 '14 at 16:07
  • Why not simply remove them or have placeholder fragments(like with an image and text saying buy this...) that you do allow to be swiped? – user Apr 06 '14 at 16:12

0 Answers0