值动画器只重复一次
我试图在结束后重复一次。我正在将其与.由于某种原因,将完成,再次触发go,但是当它到达终点时,永远不会再调用第二次。ValueAnimator
SeekBar
ListView
ValueAnimator
onAnimationEnd()
onAnimationEnd()
@Override
public View getContentView(int position, View convertView, ViewGroup parent) {
...
setupTimerBar(t);
...
}
private AnimatorListenerAdapter generateNewAnimatorListenerAdapter(final TylersContainer t) {
return new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
setupTimerBar(t);
}
};
}
private void setupTimerBar(TylersContainer t)
{
View view = t.getView();
BusTime arrivalTime = t.getBusTime();
int minutes = BusTime.differenceInMiuntes(arrivalTime, BusTime.now());
long milliseconds = minutes * 60 * 1000;
final TimerBar seekBar = (TimerBar) view.findViewById(R.id.SeekBar);
int progress = Utility.setProgress(arrivalTime, seekBar.getMax());
long duration = Utility.setAnimationDuration(progress);
seekBar.setProgress(progress);
seekBar.setAnimationDuration(duration);
seekBar.setAnimationStartDelay(milliseconds);
seekBar.setAnimatorListenerAdapter(generateNewAnimatorListenerAdapter(t));
}
该对象实际上是一个包含 a 和 a 的自定义对象,以下是相关位:seekBar
SeekBar
ValueAnimator
//Constructor
public TimerBar(Context context) {
super(context);
startTime = Calendar.getInstance();
valueAnimator = ValueAnimator.ofInt(0, getMax());
//Override the update to set this object progress to the animation's value
valueAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int animProgress = (Integer) animation.getAnimatedValue();
setProgress(animProgress);
}
});
}
//Specify the start time by passing a long, representing the delay in milliseconds
public void setAnimationStartDelay(long milliseconds){
//Set the delay (if need be) and start the counter
if(milliseconds > 0)
valueAnimator.setStartDelay(milliseconds);
valueAnimator.setIntValues(this.getProgress(), this.getMax());
valueAnimator.start();
}
//Set the duration of the animation
public void setAnimationDuration(long duration){
valueAnimator.setDuration(duration);
}
public void setAnimatorListenerAdapter(AnimatorListenerAdapter ala){
valueAnimator.addListener(ala);
}
我不明白为什么它没有重复两次以上。
我尝试过使用该属性并将其设置为,但这也没有帮助。Repeat
INIFINITI
编辑:需要明确的是,我试图得到的是一个动画,它无限期地重复,每次都有不同的持续时间。