5

I have GridView with 6 buttons and I need to detect which button is the user currently on with his finger to vibrate when user reach edge of the particular button. Is it possible to do it somehow at the layer of the buttons in GridView, or is better implement it in my gridview and count coordinates of each button edges?

Kimi
  • 6,239
  • 5
  • 32
  • 49
simekadam
  • 7,334
  • 11
  • 56
  • 79

1 Answers1

-1

You can define your own OnTouchListener to capture the events received by the View in the GridView. Something like this:

View.OnTouchListener listener = new View.OnTouchListener {
    public void onTouch ( View v, MotionEvent event ) {
        /** Check the event and the View here */
        return false; // Return false, so the system will behave as always
    }
}

public View getView ( int position, View v, ViewGroup vg ) {
    /** Create your View here */
    v.setOnTouchListener ( listener );

    /**
      Maybe you could need this too
      vg.setOnTouchListener ( listener ); 
    */
    return v;
}
Andrea Carron
  • 1,001
  • 13
  • 22