Before you set an Animation to your ViewFlipper by mViewFlipper.setInAnimation
, add the listener to it and override its onAnimationEnd
callback. There, you check which view is currently displaying on your ViewFlipper and make the button visible, if it is the last one.
// load an animation for mViewFlipper, res/anim folder must contain it
mFlipperAnimIn = AnimationUtils.loadAnimation(this, R.anim.view_flipper_in);
// set up the listener
mFlipperAnimIn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
// here, if you reach last image, change visibility of your button
if (mViewFlipper.getDisplayedChild() == mViewFlipper.getChildCount() - 1) {
buttonGoToApp.setVisibility(View.VISIBLE);
} else {
buttonGoToApp.setVisibility(View.GONE);
}
}
// leave other callbacks blank unless you want some other actions caused by animation
@Override
public void onAnimationRepeat(Animation arg0) { }
@Override
public void onAnimationStart(Animation arg0) { }
});
// finally, set up IN animation for your ViewFlipper
mViewFlipper.setInAnimation(mFlipperAnimIn);