I am trying to develop an app which will display numbers 1-10 and along with it a sound for that number.
Using the example in mobile.tutsplus for horizontal swiping, I have reached to a stage where all the numbers are displayed correctly but sound for 1
will not come when we go back from 2
. (It comes initially when my activity starts with 1
). Nor will it come for 10
.
After solving the previous problem where sounds for 1
and 2
would come at once, I now understand that instantiateItem()
will be called to pre-fetch the next entry.
I want to know at what point should I play the sound? Currently it is done in instantiateItem()
which is why I don't hear it for 1
and 10
. I thought I could do it in finishUpdate()
but I see it's getting called multiple times.
As per the training guide, for such a collection of objects FragmentStatePagerAdapter
should be used and I will be trying to move to that. But I would really like to get this to work correctly.
As you'd have guessed I'm a newbie and this is my first app. I could paste the code if required.