android鼠标滚轮事件监听方法

复制代码
@Override
    public boolean onGenericMotionEvent(MotionEvent event) {
//The input source is a pointing device associated with a display.
//输入源为可显示的指针设备,如:mouse pointing device(鼠标指针),stylus pointing device(尖笔设备)
        if (0 != (event.getSource() & InputDevice.SOURCE_CLASS_POINTER)) {
            switch (event.getAction()) {
                // process the scroll wheel movement...处理滚轮事件
                case MotionEvent.ACTION_SCROLL:
                    //获得垂直坐标上的滚动方向,也就是滚轮向下滚
                    if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f) {
                        LogUtils.d("fortest::onGenericMotionEvent down");
                       
                    }
                    //获得垂直坐标上的滚动方向,也就是滚轮向上滚
                    else {
                        LogUtils.i("fortest::onGenericMotionEvent up");
                        
                    }
                    
                    return true;
            }
        }
        return super.onGenericMotionEvent(event);
    }
相关推荐
Q26433650236 分钟前
【有源码】基于SpringBoot+Vue的居民健康体检与慢病干预管理系统-面向智慧医疗的体检预约与健康知识服务平台
java·vue.js·spring boot·mysql·毕业设计·javaweb·课程设计
事圆则缓12 分钟前
Kotlin 异步与并发:从一次搜索请求走到状态流
android·开发语言·kotlin
悠仁さん29 分钟前
非类型模板参数的特化与偏特化
java·数据结构·算法
鬼手点金35 分钟前
上下文:Agent 的眼睛
java·前端·人工智能·git·深度学习
誰能久伴不乏37 分钟前
卸载博图 TIA Portal 后,我的键盘全灭了一次
计算机外设·电脑
171320330计算机毕设编程1 小时前
计算机毕业设计 基于Hadoop的新能源汽车发展前景分析 LW PPT
java·大数据·hadoop·python·算法·随机森林·线性回归
技术小结-李爽1 小时前
【工具】怎么在终端中启动springboot项目?
java·spring boot·后端·maven
Shaoshing1 小时前
消息发送
java·开发语言
帅得不敢出门1 小时前
Android Framework定制卸载确认窗口
android