问题描述
我有一个ViewFlipper设置为自动翻页每5秒。离开了一些细节,它看起来像这样和正常工作:
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();
不过,我有我想要的自动翻转停在最后一个视图,而不是围绕循环重新开始的情况。它似乎是ViewFlipper它有一个循环的控制方法继承的类或任何没有。
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.
我怎样才能得到ViewFlipper停止通过其子视图循环,当它击中最后一个?
How can I get ViewFlipper to stop looping through its child views when it hits the last one?
请注意:给定的答案这里不适用以我的情况,因为我需要赶上ViewFlipper在其列表,也就是年底,而不依赖于用户输入。谢谢你。
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.
首先,试着听你viewflipper的翻转活动。由于您使用的是动画。您可以使用此发布的解决方案: http://stackoverflow.com/a/3813179/1594522
First, Try to listen to your viewflipper's flip events. Since you are using an animation. You may use the solution posted here: http://stackoverflow.com/a/3813179/1594522
然后,onAnimationEnd(),您可以检查viewflipper是其最后一个子视图。如果是已经在其最后一个子视图,然后调用flipper.stopFlipping()。
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().
希望帮助! :)
这篇关于如何从循环停止的Android ViewFlipper?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!