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);
    }
相关推荐
d***81727 分钟前
解决SpringBoot项目启动错误:找不到或无法加载主类
java·spring boot·后端
ᐇ95920 分钟前
Java集合框架深度实战:构建智能教育管理与娱乐系统
java·开发语言·娱乐
zhaoyufei1331 小时前
Android13删除Taskbar
android
听风吟丶1 小时前
MyBatis 深度实战:从基础映射到企业级性能优化
java·tomcat
仟濹2 小时前
【Java 基础】面向对象 - 继承
java·开发语言
6***83052 小时前
微服务搭建----springboot接入Nacos2.x
java
likuolei3 小时前
XML 元素 vs. 属性
xml·java·开发语言
自不量力的A同学3 小时前
Spring Boot 4.0.0 正式发布
java·spring boot·后端
d***29243 小时前
【spring】Spring事件监听器ApplicationListener的使用与源码分析
java·后端·spring
5***b973 小时前
解决报错net.sf.jsqlparser.statement.select.SelectBody
java