Since I finally have my simple animation repeating (by working around a bug
in Android), I get to run into the next problem.
AnimationListener.onAnimationRepeat() never gets called.
I use a button to start my animation, let it run a while, and press the
button again to stop it.
Since I want to do some things synchronized with the animation, I setup an
animation listener.
It doesn't work. Here is the main code:
private Animation.AnimationListener mAnimationListener = new
Animation.AnimationListener() {
public void onAnimationStart(Animation animation) {
scnt++;
}
public void onAnimationRepeat(Animation animation) {
rcnt++;
}
public void onAnimationEnd(Animation animation) {
ecnt++;
}
};
private OnClickListener mClickButton = new OnClickListener() {
public void onClick(View v) {
Button button = (Button) findViewById(R.id.Button01);
if (running) { // Currently running, stop it
//button.setText(R.string.Button01);
testShape.clearAnimation();
button.setText("repeat " + scnt + "," + rcnt + "," + ecnt);
} else { // Currently stopped, start it
button.setText(R.string.BtnStop);
testShape.startAnimation(testAnimation);
}
running = !running;
return;
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.Button01);
button.setOnClickListener(mClickButton);
testShape = (TextView) findViewById(R.id.TextView02);
testAnimation = AnimationUtils.loadAnimation(this,
R.anim.bounceanim);
testAnimation.setAnimationListener(mAnimationListener);
testAnimation.setDuration(1000);
return;
}
When the app is run, and the button pressed:
the animation starts running.
I let it run for several cycles and press the button again.
The result is "repeat 1,0,1" - showing that the onAnimationRepeat() was
never called.
Is this a bug, or am I missing something?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en