1
我正在使用列表视图,其中我有用于下载的按钮。ListView问题中的按钮动画
我想旋转按钮点击事件,直到一些后台下载过程工作。
旋转工作正常,但一个周期完成后有些延迟。
主要问题是,当按钮是动画和用户滚动列表不同行中的一些其他按钮也开始动画。
我有一个阵列布尔类型的保持按钮状态isDownloading []。所以我得到那个位置的按钮,启动动画,但它产生的问题
代码来获得按钮来回动画:
else if (isDownloading[position] == true)
{
holder.downloadListBtn.setBackgroundResource(R.drawable.downloading);
LinearLayout layout = (LinearLayout) holder.downloadListBtn.getParent();
Button button = (Button) layout.getChildAt(0);
ButtonAnimate(button);
}
代码动画按钮:
public void ButtonAnimate(Button b)
{
RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setDuration(4500);
animation.setRepeatCount(100);
b.startAnimation(animation);
}