asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
package com.aizheke.aizheked.widget;

import com.aizheke.aizheked.utils.AzkHelper;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.Gallery;

public class OnebyoneGallery extends Gallery {

    public OnebyoneGallery(Context context) {
        super(context);
    }
    
    public OnebyoneGallery(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

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

    private boolean isScrollingLeft(MotionEvent e1, MotionEvent e2) {
        AzkHelper.showLog("gallery:" + e2.getX() + ", " + e1.getX());
        return e2.getX() > e1.getX();
    }   
   
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {
        int kEvent;
           if (isScrollingLeft(e1, e2)) {
            // Check if scrolling left
            kEvent = KeyEvent.KEYCODE_DPAD_LEFT;
           } else {
            // Otherwise scrolling right
            kEvent = KeyEvent.KEYCODE_DPAD_RIGHT;
           }
           onKeyDown(kEvent, null);
           return true;    
    }
}
posted on 2012-03-07 18:23 汪杰 阅读(251) 评论(0)  编辑 收藏 引用 所属分类: Java
只有注册用户登录后才能发表评论。

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 457546
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜