如何从视图中获取动画

How to get Animation from View

我在 Adapter

的点击事件中为 ProgressBar 设置了动画
ObjectAnimator animation = ObjectAnimator.ofInt(holder.progressbar, "progress", 0, 100);
animation.setDuration(PROGRESS_TIME);
animation.setInterpolator(new DecelerateInterpolator());
animation.addListener(new Animator.AnimatorListener() {

@Override
public void onAnimationStart(Animator animator) {
    Toast.makeText(context,"HELL_Start",Toast.LENGTH_SHORT).show();
}

@Override
public void onAnimationEnd(Animator animator) {
    //do something when the countdown is complete
    Toast.makeText(context,"HELL_OFF_END",Toast.LENGTH_SHORT).show();
}

@Override
public void onAnimationCancel(Animator animator) {
    Toast.makeText(context,"HELL_OFF_Cancel",Toast.LENGTH_SHORT).show();
}

@Override
public void onAnimationRepeat(Animator animator) { }
});

animation.start();

我正在尝试使用

ProgressBar 获取动画(当列表项值更改时)

AlphaAnimation animation = (AlphaAnimation)mProgressBar.getAnimation();

但它正在返回 null

您可以将动画对象设置为关联视图的标签。

holder.progressbar.setTag(animation);

稍后检索:

ObjectAnimator animator = (ObjectAnimator) holder.progressBar.getTag();
// Do something with animator