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);
    }
相关推荐
sharemylove2 小时前
Java集合框架全面详解
java·开发语言·经验分享·笔记·学习
FYKJ_20103 小时前
springboot众创项目团队管理系统94666-计算机课程设计、毕业设计
java·vue.js·spring boot·后端·python·spark·课程设计
摇滚侠4 小时前
《On Java 中文版 基础卷》阅读笔记 内部类 20
java·笔记·python
好的佩奇4 小时前
Dart 之 JSON
android·flutter·dart
_祝你今天愉快5 小时前
Android 事件传递机制:[一] 事件分发机制详解
android
FYKJ_20107 小时前
springboot贫困生认定管理系统59009-计算机毕业设计、课程设计
java·javascript·vue.js·spring boot·后端·django·课程设计
考虑考虑7 小时前
JDK27中的结构化并发
java·后端·java ee
吃我一窝jio9 小时前
Java IO流核心分类与应用
java·开发语言·笔记
Digitally10 小时前
如何将电脑上的联系人传输到安卓手机(4 种方法)
android
这个昵称不容易10 小时前
租房管理系统设计与实现:16 张表、185 个接口的 SpringBoot 前后台项目
java·springboot·毕设