android - Animation BEFORE activity change -


i'm trying simple, can't understand why it's not working.
i'm trying is: when touch imageview, show animation on it. , then, when animation ends start new activity.
instead, happens new activity starts right away , animation not shown.

here animation xml:

<rotate android:interpolator="@android:anim/decelerate_interpolator"     android:fromdegrees="-45"     android:todegrees="-10"     android:pivotx="90%"     android:pivoty="10%"     android:repeatcount="3"     android:fillafter="false"     android:duration="10000" /> 

and code use call it:

public void oncreate( bundle savedinstancestate ) {     final imageview ib = (imageview)this.findviewbyid( r.id.photo );     ib.setonclicklistener( new onclicklistener( ) {          @override         public void onclick( view v )         {             animation hang_fall = animationutils.loadanimation( curriculum.this, r.anim.hang_fall );             v.startanimation( hang_fall );             intent = new intent( thisactivity.this, nextactivity.class );             thisactivity.this.startactivity( );         }// end onclick     } ); }// end oncreate 

as see tried putting loooong time animation, doesn't work. nextactivity starts right away, doesn't wait animation in thisactivity finish.
idea on why happens?

that's because you're starting intent , animation @ same time. need start intent after animation over, this:

@override public void onclick( view v ) {     animation hang_fall = animationutils.loadanimation( curriculum.this, r.anim.hang_fall );     hang_fall.setanimationlistener(new animation.animationlistener()         {             public void onanimationend(animation animation)             {                 intent = new intent( thisactivity.this, nextactivity.class );                 thisactivity.this.startactivity( );             }              public void onanimationrepeat(animation animation)             {                 // nothing!             }              public void  onanimationstart(animation animation)             {                 // nothing!             }         });     v.startanimation( hang_fall ); }// end onclick 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -