boolean buttonflag=false;
Editbutton.setOnClickListener( new OnClickListener()
{
@Override
public void onClick( View v )
{
buttonflag=true;
}
}
error im getting is “Cannot refer to a non-final variable buttonflag inside an inner class defined in a different method” what i want to do is when i press the Editbutton i want the buttonflag to be true..Can any one explain the reason and a fix for this problem?
The error message is pretty straight forward. Since
buttonflagis not final, you cannot access it in yourOnClickListeneranonymous class. Two possible solutionsMake it final. However, then you cannot modify it, and you have to choose the one-dimensional array approach resulting in