I have a ViewFlipper set to auto-flip every 5 seconds. Leaving out some of the details, it looks like this and works fine:
ViewFlipper flipper = (ViewFlipper) findViewById(R.id.myflipperid);
flipper.setFlipInterval(5000);
flipper.setInAnimation(inFromRightAnimation());
flipper.setOutAnimation(outToLeftAnimation());
flipper.startFlipping();
However, I have a case where I want the auto-flipping to stop at the last view, rather than looping around to start over again. It doesn’t seem that ViewFlipper or any of the classes it inherits from have a looping control method.
How can I get ViewFlipper to stop looping through its child views when it hits the last one?
Note: the answer given here doesn’t apply to my case, as I need to catch the ViewFlipper at the end of its list, i.e., without depending on user input. Thanks.
I haven’t tried this my self but I hope this will help.
First, Try to listen to your viewflipper’s flip events.
Since you are using an animation. You may use the solution posted here: https://stackoverflow.com/a/3813179/1594522
Then, onAnimationEnd(), you can check if the viewflipper is on its last child view.
If it is already on its last child view, then call flipper.stopFlipping().
Hope that helps! 🙂