除非
(current / total) * 100
不是每次都返回零。
该方法返回0,因为在划分两个整数值时,如果分母大于分子,则返回0。检查
the explained answer
. 你可以改变你的
getProgress()
方法的实现。
public class ModelProgress extends BaseObservable {
private int total=100;
private int current;
public void setCurrent(int current) {
this.current = current;
notifyPropertyChanged(BR.progress);
}
@Bindable
public int getProgress() {
return current * 100 / total;
}
}
还要检查你必须初始化
total
第一。检查你是如何计算进度的。
确保不要忘记设置模型。
modelProgress=new ModelProgress();
mainBinding.setModel(modelProgress);