Gallery 移动一个图像

我使用 Gallery 来显示一些图像。当手指触摸或在屏幕上移动时,图像就变成之前的图像或者下一个图像。但是当移动的距离大点,gallery 可能改变更多的图像。我想限制它每次移动都移动图像。

Gallery gallery = (Gallery) this.findViewById(R.id.gallery_photo);
gallery.setAdapter(new GalleryAdapter(this listPhotoURL));
gallery.setSelection(i);

listPhotoURL 是字符串数组,在 GalleryAdapter 中只显示 listPhotoURL[i] 到 imageview 中。如何实现?或者如何修改监听方法?

你应该重写 Gallery 中的这个方法:

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                       float velocityY) {        
    return false;
}