gallery每滑动一次滑过好几屏的问题

来源:互联网 发布:tensorflow 常用算法 编辑:程序博客网 时间:2024/04/28 15:36

在项目中遇到使用gallery实现左右滑屏的时候,发现一个问题就是滑动一次gallery会滑过好几张图片,到网上查了些资料,找到了解决方法就是继承gallery,然后重写onFliping方法让其返回false.代码如下:

package com.gallery;

public class MyGallery extends Gallery{

     public GalleryFlow(Context context) {
        super(context);
      }
    public GalleryFlow(Context context, AttributeSet attrs) {
        super(context, attrs);
     }
    public GalleryFlow(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
     }

   @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
      float velocityY) {
     // TODO Auto-generated method stub
     return false;
    }

}

注:在xml中定义gallery时,引用的是<com.gallery.MyGallery>

原创粉丝点击