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);
    }
相关推荐
一叶落43818 分钟前
LeetCode 54. 螺旋矩阵(C语言详解)——模拟 + 四边界收缩
java·c语言·数据结构·算法·leetcode·矩阵
最初的↘那颗心21 分钟前
Prompt 工程实战:五要素框架与 Spring AI 模板化落地
java·大模型·prompt工程·spring ai·ai应用开发
墨狂之逸才1 小时前
React Native 移动项目目录导致的 Android 编译失败问题及解决方案
android·react native
东离与糖宝1 小时前
Java 21 虚拟线程与 AI 推理结合的最新实践
java·人工智能
feng一样的男子1 小时前
住在手机里的“小龙虾” (OpenClaw):接入本地模型,解决记忆“装死”顽疾
android·ai·智能手机·openclaw
hongtianzai2 小时前
MySQL中between and的基本用法
android·数据库·mysql
菜鸟小九2 小时前
hot100(71-80)
java·数据结构·算法
大傻^2 小时前
LangChain4j 1.4.0 快速入门:JDK 11+ 基线迁移与首个 AI Service 构建
java·开发语言·人工智能
代码探秘者2 小时前
【大模型应用】4.分块之六大策略
java·数据结构·后端·python·spring