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);
    }
相关推荐
毕设源码-赖学姐3 小时前
【开题答辩全过程】以 高校评教评学系统的设计与实现为例,包含答辩的问题和答案
java·eclipse
老华带你飞3 小时前
博物馆展览门户|基于Java博物馆展览门户系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot·后端
路边草随风4 小时前
iceberg 基于 cosn 构建 catalog
java·大数据
It's now4 小时前
Spring Framework 7.0 原生弹性功能系统讲解
java·后端·spring
点PY4 小时前
C++ 中 std::async 和 std::future 的并发性
java·开发语言·c++
_李小白4 小时前
【Android FrameWork】第二十四天:Activity生命周期是如何运行的
android
ytttr8734 小时前
基于C#的CAN总线数据解析BMS上位机
android·unity·c#
一 乐4 小时前
人事管理系统|基于Springboot+vue的企业人力资源管理系统设计与实现(源码+数据库+文档)
java·前端·javascript·数据库·vue.js·spring boot·后端
带刺的坐椅4 小时前
Solon AI 开发学习19 - 结合 Solon Flow 实现 ReAct 效果
java·ai·chatgpt·llm·openai·solon·deepseek
CoderYanger4 小时前
Java SE——12.异常(≠错误)《干货笔记》
java·开发语言