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);
    }
相关推荐
wangbing11251 分钟前
下划线数字字面量
java
星间都市山脉12 分钟前
RecoveryUI 圆角屏安全边距配置及代码调用链
android·java·linux·windows·ubuntu
sunshine22 girl14 分钟前
Java学习五 面向对象高级5 内部类4-匿名内部类(重点)
java·学习
java_nnnn18 分钟前
Spring Boot 快速上手:从 Maven 到第一个 Controller
java·spring·java-ee·maven
夕除23 分钟前
redis--集群
java·redis
蜗牛互联网24 分钟前
OLMo-core 3的token gerrymandering提醒:MoE路由要按时间窗验收
java·人工智能·wpf
奇牙coding28 分钟前
Codex C接 配置教程:的 字段从迁移时必须写完整后缀,填旧值或省略 会静默回退默认模型
java·c语言·数据库·ai
打工仔折腾 AI31 分钟前
DiPlay 实测:iPhone 绕过硬件盒子直连 BYD 车机的思路拆解
android·人工智能·后端·python·gradle·iphone·ai agent 实战
卓怡学长37 分钟前
w193基于springboot“乐通黄骅”电动车智能充电服务小程序
java·spring boot·spring·小程序·intellij-idea
hengdonghui1 小时前
Writeup 4 NUAA 2017 robots
android·ctf·re