Basically, I am implementing a reversi app for android, and I am currently trying to update an element in a 2d array. The call is in an onClickListener which is in a loop that was used to set up the reversi board. The problem is that once a piece has been placed, the element isPositionEmpty is supposed to change to false, however, it does not. Here is a snippet of the code:
for(int n = 0; n < 8; n ++){
...
for(int i = 0; i < 8; i++ ){
final ImageView button = new ImageView(this);
final int countN = n;
final int countI = i;
...
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String buttonID = String.valueOf(button.getId());
Log.d("buttonPressedID",buttonID);
Log.d("isPositionEmpty", boardString);
board[countI][countN].isPositionEmpty = false;
Help is greatly appreciated! thanks in advance!