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);
    }
相关推荐
captain3763 小时前
MyBatis(入门5)其他查询操作
java·数据库·spring boot·mybatis
Novproxy_Z3 小时前
商用代理避坑:如何识别商家拿机房 IP 冒充住宅 IP
java·网络·tcp/ip
文丑颜不良啊4 小时前
LeetCode1481~1500题目解析
java·leetcode
2601_962885724 小时前
quotes 字段全解:涨跌幅、振幅、换手率的口径与单位
java·前端·spring
前端精髓4 小时前
调用openrouter的免费API模型
java·前端·javascript
步行cgn5 小时前
Spring MVC 拦截器 Interceptor 详解:从执行流程到实战应用
java·spring·mvc
文丑颜不良啊5 小时前
LeetCode1381~1400题目解析
java·leetcode
开开心心_Every5 小时前
快速隐藏程序工具自定义快捷键一键切换
java·开发语言·前端·spring·智能手机·word·intellij-idea
萧瑟余晖6 小时前
Spring Batch核心模型与快速上手详解
java·spring·batch
缓慢更新6 小时前
AI 辅助生成单测:从接口定义到用例的流水线
java·服务器·前端·网络·数据库·人工智能