Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to jump straight to second view in ViewAnimator

I have a ViewAnimator (ViewSwitcher to be precise) with fade in/out animations associated to it and two Views which I transition between using the ViewAnimator.showNext() and ViewAnimator.showPrevious() methods.

There is a requirement in my app where sometimes I need to start straight from the second View, without showing a fade animation in going from the first View to the second. Anyone know if there is a straightforward way to accomplish this without having to mess around with the in/out animations associated to my ViewAnimator?

Note: I have tried calling ViewAnimator.setDisplayedChild(1) but that also animates the transition.

like image 550
Adil Hussain Avatar asked Jun 27 '12 17:06

Adil Hussain


1 Answers

I looked around and waited for a response but I'm guessing it's not possible. So, in the absence of a better solution, set your ViewAnimator's in/out animations to null when you want to jump straight to a particular child View of your ViewAnimator, as follows:

myViewAnimator.setInAnimation(null);
myViewAnimator.setOutAnimation(null);
myViewAnimator.setDisplayedChild(childIndex);

If anyone knows a better way - rather than playing with the ViewAnimator's in/out animations - please share!

like image 174
Adil Hussain Avatar answered Nov 15 '22 19:11

Adil Hussain