Whether I set the onClick method programatically or in the xml file, I don't know how I can pass an extra parameters through it. In the following code:
for (int i = 0; i < 6; i++) {
rollView[i].setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
changeKeepRoll(i);
}
});
}
I'm setting an onClickListener for 6 different TextViews and I want to call the method changeKeepRollwhich takes an integer parameter as an input, however I get the error 'Variable 'i' is accessed from within inner class, needs to be declared final'. What does this mean and how can I rectify it?