ANDROID onTouchListener on button array

Viewed 543

I have put a lot of buttons (16*16) in a button array. The buttons numbers are directly related to changes they should do in another array (e.g. button[12][7] sets the value of stat[12][7] to 1)

So I thought it's possible to put on single line in the onTouch method that reacts to every button. Example (of course, not working)

public boolean onTouch(View arg0, MotionEvent arg1) {
if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
if(arg0 == button[int a][int b]){stat[a][b]=1};

In this pseudocode, the button would create 2 ints that describe the 2 dimensions of the array which get passed to the stat array.

If anyone had a solution for this, he would save me a few hours this night.

Thanks for your answers.

4 Answers
Related