Cannot Refer To The Non-final Local Variable Button Defined In An Enclosing Scope, Random Method Error
I am getting an error in my project with eclipse: Cannot refer to the non-final local variable button defined in an enclosing scope This my class: import android.app.Activity; im
Solution 1:
Change your code to private void startRandomButton(final Button button)
. The compiler wants to make sure that a reference is not being re-assigned inside a method of an anonymous class.
From java-8, If your reference is effectively-final, then you don't even have to mark those arguments as final
Post a Comment for "Cannot Refer To The Non-final Local Variable Button Defined In An Enclosing Scope, Random Method Error"