I am trying to build a tic tac toe application using the android:button. Right now I am thinking of the best way to design this because I am not sure how to detect buttons that are adjacent to each other. Right now i have things hard coded, how do i detect if buttons are adjacent to one another?
Share
Use id with row/column major pattern / 2D array of Buttons which makes is easy to determine adjacent buttons like(3×3) :
or
Here is a complete sample for you:Tic-Tac-Toe, also take a look at Tic-Tac-Toe-2