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);
    }
相关推荐
panxianren4 小时前
Bun 1.4 的 bun test --parallel 将 4 秒的测试套件缩短到约 1 秒
java·javascript
sunshine22 girl5 小时前
Java学习七 Java 项目实战2-注册业务
java·学习
省钱兄--zs6 小时前
北京24小时自助健身房系统软件开发实战:从架构设计到部署指南
java·数据仓库·spring boot·小程序·需求分析
youdexiang6 小时前
Android录音软件时间关键词检索功能分析
java·人工智能
sunshine22 girl7 小时前
Java学习七 Java 项目实战1-项目创建和主页面搭建
java·开发语言·学习
code2cat7 小时前
Java进阶篇之AtomicStampedReference:引用回到原值,版本戳仍能记住变化
java·cas·并发编程·aba
泡茶喝茶写代码9 小时前
A股量化数据工程:从 REST 接口到策略信号(第 8 篇):成长能力因子:营收与利润增速
java·python·股票数据api·股票数据api接口·股票量化数据api·股票量化数据接口·股票数据api数据
三少爷的鞋9 小时前
AI 时代,我们都将成为通才型开发者:只懂 Android,已经不够了
android
\光辉岁月/9 小时前
7.javase-面向对象
java·开发语言
weixin_5310946910 小时前
heap_4内存管理
java·开发语言·算法