[sourcecode language="java"]
public class GalleryFling extends Gallery{
public GalleryFling(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public GalleryFling(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
int keyCode;
if(e2.getX() > e1.getX()){
keyCode = KeyEvent.KEYCODE_DPAD_LEFT;
}
else{
keyCode = KeyEvent.KEYCODE_DPAD_RIGHT;
}
onKeyDown(keyCode, null);
return true;
}
}
[/sourcecode]