Kind of a silly problem I'm facing here... Basically I'm in a For-loop and within this loop I'm always calling a function to make a button. But in this function I want to pass the loop iterator as it's changing to differentiate the buttons. But then it tells me I need to make the loop iterator "final" which means it doesn't change!
Well my problem will make more sense with some skeleton code:
for(int i = 0; i < appList.size(); i++) {
//some other stuff including creating the below button 'btn'
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//set some attribute based on i
//but when I do this it only sets based on the greatest value of i (!)
}
});
}
Meh kinda silly problem I know... I'm new to Java though!
Cheers.