我在适配器中的单击事件中设置了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
发布于 2017-09-09 13:02:59
可以将动画对象设置为关联视图的标记。
holder.progressbar.setTag(animation);而不是稍后再检索:
ObjectAnimator animator = (ObjectAnimator) holder.progressBar.getTag();
// Do something with animatorhttps://stackoverflow.com/questions/46127089
复制相似问题