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);
    }
相关推荐
电脑小管家几秒前
蝰蛇鼠标驱动怎么安装?全型号驱动下载方法汇总
windows·驱动开发·计算机外设·电脑·游戏程序
雨中飘荡的记忆2 分钟前
Spring MVC详解
java·spring
即将进化成人机5 分钟前
Spring Boot入门
java·spring boot·后端
苏打水com7 分钟前
HTML/CSS 核心考点详解(字节跳动 ToB 中台场景)
java·前端·javascript
-大头.8 分钟前
Spring批处理与任务管理全解析
java·linux·spring
私人珍藏库12 分钟前
[Android] 轻小说文库(1.23)
android·app·安卓·工具
科普瑞传感仪器16 分钟前
基于六维力传感器的机器人柔性装配,如何提升发动机零部件装配质量?
java·前端·人工智能·机器人·无人机
她说..16 分钟前
Java AOP完全指南:从原理到实战(全套知识点+场景总结)
java·开发语言·spring·java-ee·springboot
-大头.16 分钟前
Spring进阶:构建模块化RESTful系统全攻略
java·spring·restful
Java林间18 分钟前
飞书机器人消息推送策略模式Java实践
java