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);
    }
相关推荐
小道仙975 小时前
jenkins对接、jenkins-rest
java·servlet·jenkins·jenkins-rest
莫寒清7 小时前
MinIO
java
谁刺我心8 小时前
qml自定义鼠标
计算机外设
Java后端的Ai之路9 小时前
【JDK】-JDK 21 新特性内容
java·开发语言·后端·jdk·jdk21
冬奇Lab10 小时前
应用异常退出实战分析:一次"幽灵杀手"引发的车载系统故障排查
android·性能优化·debug
黎雁·泠崖10 小时前
Java常用类核心详解(七):正则表达式 Regex 从入门到实战
java·开发语言·正则表达式
sheji341611 小时前
【开题答辩全过程】以 婚纱影楼管理系统为例,包含答辩的问题和答案
java·eclipse
LuDvei11 小时前
LINUX文件操作函数
java·linux·算法
葵续浅笑11 小时前
从Spring拦截器到Filter过滤器:一次报文修改加解密的填坑经验
java·后端·spring