質問

I am making a game of Gomoku in Android. I have made a grid out with drawLine(): http://i.stack.imgur.com/Mm4HZ.jpg

I am now trying to make the app detect presses within the small squares. I was thinking perhaps I could generate buttons to be in the center of each square. I have the height/width of a single square saved to varibles so getting the center points to each square shoudln't be difficult. However, how should I dynamically generate buttons where each corresponds to a certain [i][j] in a 10 * 10 matrix where the field data is stored?

役に立ちましたか?

解決

You can register an onClickEvent with any view in android. What you want is an invisible view the area of the places were you want click events. I suggest using buttons or something visual so that you can see where the areas are, register the click events for each view, then hide the views so that they are invisible.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top