i take a Int from DB with this code in a function:
Cursor res = mDBHelper.contr();
while (res.moveToNext()) {
percA = res.getInt(1);......
After i use this function to animate the number percA:
private void startCountAnimation() {
ValueAnimator animator = ValueAnimator.ofInt(0, percA);
animator.setDuration(1500);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
percA.setText(animation.getAnimatedValue().toString());
}
});
animator.start();
}
But this code doesn't work. The error is: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference.
I try to change the property of variable percA and the property of function but i can't find the problem. Why my variable points to null?
Thanks for your help.