0

I have a function to which i am passing a View as parameter. Now when i use statusView in the function onAnimationEnd , the compiler gives a message to change the modifier of statusView to final . So i dont understand why this is necessary?

private void showProgress(Context c, View statusView) {


            statusView.setVisibility(View.VISIBLE);
            statusView.animate().setDuration(shortAnimTime)
                    .alpha(show ? 1 : 0)
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            statusView.setVisibility(show ? View.VISIBLE
                                    : View.GONE);
                        }
                    });

}
Diffy
  • 2,339
  • 3
  • 25
  • 47

1 Answers1

0

Since the variable statusView is outside of the object created by AnimatorListenerAdapter, it must be known at compile time and, thus, be declared final. However, you can just resolve it by declaring it final in the parameter list (in line 1).

user1742364
  • 154
  • 1
  • 8