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);
    }
相关推荐
weixin_394758034 小时前
CRMEB Pro 优惠券:下单怎么核销,取消/退款怎么返券
android
EatFan4 小时前
Spring Boot 4.0 升级清单:JDK 基线、Jakarta 命名空间、Observation API 与第三方组件兼容一次讲清
java·spring boot·后端
辰海Coding4 小时前
平台如何接入一台物联网设备?又该如何设计它的通信协议?
java·物联网
代码民工正电荷4 小时前
JAVA重要知识点和集合
java·开发语言
alexhilton6 小时前
Android 17 内存预算成为必修课
android·kotlin·android jetpack
李少兄6 小时前
IDEA Apifox Helper 插件踩坑:2.0.15-243 版本“导出指定接口”参数描述丢失问题解析与修复方案
java·ide·intellij-idea
努力攀登的小k6 小时前
《新手练表:从建表到删表全操作|从零学会表操作》
java·数据库·mysql
Yetian_20007 小时前
Postman测试上传图片文件接口
java·postman
爪哇碎碎念7 小时前
【Java】从一次 cache.get(key) 进去:缓存击穿一瞬间打出 200 次 DB,JDK 17 实测三种解法
java·redis·缓存
csdn_aspnet7 小时前
Java 使总距离最短的最佳点位置(Optimum location of point to minimize total distance)
java·算法