Alex Rivera | Logout

Listener for ViewFlipper widget flipping events

Asked 2010-09-28T13:19:37.720
28

I have a ViewFlipper implementation that needs to be improved. This ViewFlipper has three child views. Basically, I want an indicator on which child view is currently active. My ViewFlipper is just a part of a complex layout which also has list views, etc.

Switching of views is also automatic and done in a specified interval.

From Android's SDK reference, I haven't seen any listener for when the ViewFlipper changes the child view.

Do you guys know of a way I can have a listener for that event?

Or are there alternative ways I can implement this feature besides using ViewFlipper ?

Thanks!

Edit
Report

1 Answer

43

If you apply animation (out or in animation) on view switching, you can set listener to an animation and, for example, act on animation end.

   viewFlipper.getInAnimation().setAnimationListener(new Animation.AnimationListener() {
      public void onAnimationStart(Animation animation) {}
      public void onAnimationRepeat(Animation animation) {}
      public void onAnimationEnd(Animation animation) {}
   });
answered 2010-09-28T13:28:49.400

Your Answer