我建立一个自定义视图包含3个进度条,所以我有一个数组变量,像这样的:ObjetctAnimator与数组变量
float[] progress = new float[3];
而且我想用“ObjectAnimator”更新具体进展条目;这里有相关的方法:
public void setProgress(int index, float progress) {
this.progress[index] = (progress<=100) ? progress : 100;
invalidate();
}
public void setProgressWithAnimation(int index, float progress, int duration) {
PropertyValuesHolder indexValue = PropertyValuesHolder.ofInt("progress", index);
PropertyValuesHolder progressValue = PropertyValuesHolder.ofFloat("progress", progress);
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(this, indexValue, progressValue);
objectAnimator.setDuration(duration);
objectAnimator.setInterpolator(new DecelerateInterpolator());
objectAnimator.start();
}
,但我得到这样的警告:
我也试图与二传手包含数组(setProgress (float[] progress)
),但仍得到了一个错误:Method setProgress() with type float not found on target class
所以我会很高兴知道如何使用ObjectAnimator数组变量,
感谢
简单地用'ObjectAnimator#ofInt(对象目标,弦乐propertyName的,诠释.. 。values)' – pskink
@pskink。谢谢,但我已经尝试它并得到:'方法setProgress()与类型浮动没有找到目标类',对不起,我没有写在问题,我也试过了... – AsfK