0

I have many views (FrameLayouts) on my screen - each has a SimpleOnGestureListener set as the onTouchListener.

I'm correctly getting the onSingleTapConfirmed method being fired when I tap one of these views, but I can't work out how to determine which view was tapped?

Is there a simple way to do this from the MotionEvent?

Matt Fellows
  • 6,512
  • 4
  • 35
  • 57

1 Answers1

5

I have many views (FrameLayouts) on my screen - each has a SimpleOnGestureListener set as the onTouchListener.

Save a reference to the View in the OnTouchListener, then when a gesture callback fires you'll already know which View was touched:

public boolean onTouch(View v, MotionEvent event) {
    // Remember which View was touched
    mCurrent = v; 

    // Pass event to gesture listener, etc
}

Now use mCurrent in onSingleTapConfirmed() and any other method.

Sam
  • 86,580
  • 20
  • 181
  • 179
  • Duh... That'll teach me to copy and paste code without reading it - hadn't seen that I have the View in the onTouch event... Thanks – Matt Fellows Feb 25 '13 at 15:45