android - 图库移动一张图片

标签 android 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;
}

关于android - 图库移动一张图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8572037/

相关文章:

android - 如何使用 maxLength 以 3 个点结束 TextView

android - 无法保持服务在 Android 中运行

jquery - 通过鼠标悬停/移出 div 淡入/淡出 div 中的元素

android - ViewPager 可能具有无限数量的页面

android - 有没有办法覆盖 Android Gallery 小部件默认动画,例如插值器

android - 如何在android中设置背景图片

Android openFileOutput - 没有创建存储的权限

android - 如何将我的 imageView 图像保存到图库中(Android 开发)

java - Android Studio 无法在 OpenSUSE 上启动(打开的文件太多)

android gallery 自定义适配器