Advertisement
Guest User

Untitled

a guest
Jun 19th, 2012
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public class ExtendedGallery extends Gallery
  2. {
  3. public ExtendedGallery(Context context, AttributeSet attrs, int defStyle) {
  4. super(context, attrs, defStyle);
  5. }
  6.  
  7. public ExtendedGallery(Context context, AttributeSet attrs) {
  8. super(context, attrs);
  9. }
  10.  
  11. public ExtendedGallery(Context context)
  12. {
  13. super(context);
  14. }
  15.  
  16. // ---------------> to show one image at a time
  17.  
  18. private boolean isScrollingLeft(MotionEvent e1, MotionEvent e2){
  19. return e2.getX() > e1.getX();
  20. }
  21.  
  22. @Override
  23. public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){
  24. int kEvent;
  25. if(isScrollingLeft(e1, e2)){ //Check if scrolling left
  26. kEvent = KeyEvent.KEYCODE_DPAD_LEFT;
  27. }
  28. else{ //Otherwise scrolling right
  29. kEvent = KeyEvent.KEYCODE_DPAD_RIGHT;
  30. }
  31. onKeyDown(kEvent, null);
  32. return true;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement