Viish a écrit:Bon problème résolu, d'une manière immonde mais au moins ça marche :
+ 1
Le framework d'animations Android te propose de definir un AnimationListener pour gerer le debut/la fin ou la repetition de ton animation.
Ca se fait de cette maniere pour gerer la fin d'une animation :
package com.test.AnimationFwk;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
public class AnimationFwk extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Define a button and its layout
Button b = new Button(this);
b.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
// Define an animation
Animation a = new TranslateAnimation(0, 100, 0, 100);
a.setDuration(3000);
a.setAnimationListener(myAnimationListener);
b.setAnimation(a);
// Define the view
LinearLayout ll = new LinearLayout(this);
ll.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
ll.addView(b);
setContentView(ll);
// Start the animation
a.start();
}
AnimationListener myAnimationListener = new AnimationListener(){
public void onAnimationEnd(Animation arg0) {
// TODO Auto-generated method stub
AfterAnimationProc();
}
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
};
public void AfterAnimationProc(){
Log.e("AnimationFwk", "Do someting after animation !");
}
}
Enjoy !
W
Note : Ce comportement d'abonnement a la fin d'une animation est exactement le meme dans le framework SL DotNet.
www.stuffbee.com