Search code examples
androidandroid-arrayadapterandroid-gallery

What method is called when an Android Gallery 'snaps'?


When you use the Gallery class, and view pictures on it, it 'snaps'. What method is called when this happens?

Based on my observation, this is what happens on getView() method of an Adapter

  1. Gallery displays image 1
  2. User touches the screen and slowly gestures to go to the next image 2
  3. Adapter.getView() is called.
  4. User cancels the gesture so the Gallery displays image 1 ('snaps' to image 1)
  5. Adapter.getView() is not called anymore.

Thanks!


Solution

  • Problem solved. I used setOnItemSelectedListener and the method

    public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
    

    is what I need