我用画廊来展示几张图片。 当手指触摸并在屏幕上移动时,图片到上一张或下一张。 但当移动距离较大时,画廊可能会收取多张图片。 我想限制它每次移动一张图片。 我的代码:
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;
}
关于android - 图库移动一张图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8572037/