views:

174

answers:

1

Hi,

I am using a Gallery based Coverflow, as suggested here.
Is there an event that can be caught, which indicates that a single shift (either left or right) has been made in my gallery/coverflow?
To be clear, if I gave the gallery a decent swipe and my center (selected) image has changed 8 times, I would like to catch this event 8 times.

OnFling() just indicates a single swipe - regardless how many items have shifted.
Getting getSelectedItemPosition() before and after the swipe doesn't help since I need to do some work on every shift.
It will also be nice while I am at it, to get the direction of the shift - either right or left.
Thanks in advance,
Rob

A: 

If I understand you correctly you should implement this interface and set it to you Gallery with setOnItemSelectedListener method, also setCallbackDuringFlingmight be usefull.
To get fling direction you can save last selected position and compare it with new one.

Nikolay Ivanov
Nikolay, thank you for your reply. I have already tried both your suggestions, but they do not accomplish what I need. They are not called on every shift of an item and I need to do some work on every item shift, meaning - every time the image in the center changes.
Rob
Hi Nikolay, although this solution does not raise an event on every shift, it does do so on every 2 or 3 shifts. If my gallery has 20 elements, I can catch events for elements 0,2,5,7,9,11,14,16,19 - for example, which is good enough. Therefore, I embrace your solution and thank you very much.
Rob