Q: Trying to make a progress bar that animates between two ints that change frequently I have a little guess-the-hex-value game that I'm making for my first Android app that I am trying to display the percentage correct your guess is with a progress bar. I have the progress bar working fine, but I'm having trouble getting the animation to work.
Here is my animation:
protected ObjectAnimator progressAnimator;

then on OnCreate..
progressAnimator = ObjectAnimator.ofInt(percentageBar, "progress", percentageCorrectOld, percentageCorrectNew);
progressAnimator.setDuration(5000);

//i'm not sure where I should be starting this animation?
progressAnimator.start();

And here I have a textChanged Listener that detects when the hex guess is updated where I set the int percentageCorrect
@Override
public void afterTextChanged(Editable s) {

//sets the old percentage correct, which is set to 0 on onCreate
percentageCorrectOld = percentageCorrect;

//calculates the percentageCorrect using color comparison deltaE equation (irrelevant)
percentageCorrect = 100 - (int) ((deltaE / 375.5955) * 100);

//sets the newly calculated percentageCorrect to the new value
percentageCorrectNew = percentageCorrect;

//sets the text of the progress bar to the new value
percentageBarText.setText(""+percentageCorrect);

//sets the progress of the bar
percentageBar.setProgress(percentageCorrect);
}

Basically I am not sure where I should be starting the animation? Starting it in the afterTextChanged listener seems wrong as it would just restart the animation over and over.. (also it doesn't work, tested it). Starting it on onCreate doesn't work, either. I am getting the correct percentageCorrectOld and percentageCorrectNew values in the afterTextChanged listener, but the animation just won't play when I need it to. 
Any help? I am really unsure of the best way to use this animation. Thanks!
