Hi,
I need to implement a gallery which scrolls one item at a time, and
which can do 'autoscroll': i.e. every couple of seconds, it
automatically scrolls to the next item.
I extended Gallery, overriding onFling to ignore the fling event and
instead simulate a DPAD arrow left or right in order to move a single
item at a time:
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY) {
int kEvent;
if(isScrollingLeft(e1, e2)){ //Check if scrolling left
kEvent = KeyEvent.KEYCODE_DPAD_LEFT;
}
else{ //Otherwise scrolling right
kEvent = KeyEvent.KEYCODE_DPAD_RIGHT;
}
onKeyDown(kEvent, null);
return true;
}
This works well.
For the auto scroll, I create a handler and postDelayed a runnable
which simulates the same DPAD key press in the same way:
handler.postDelayed(new Runnable() {
public void run() {
onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT, null);
}
}, AUTO_SCROLL_INTERVAL);
but this doesn't do anything!! I know the runnable gets executed as
expected at the correct interval, since I logged it and confirmed
this, but the onKeyDown does not cause the gallery to scroll or switch
items.
Why would this work in one method and not another?
I looked into the Gallery code for clues, but found nothing! It seems
as though it should work.
Please, I'm stumped... any ideas?
Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en