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);
    }
相关推荐
房开民9 分钟前
c++总结
java·开发语言·c++
好大哥呀18 分钟前
C++ 多态
java·jvm·c++
毕设源码-赖学姐23 分钟前
【开题答辩全过程】以 基于Java的医院器材管理系统的设计与实现为例,包含答辩的问题和答案
java·开发语言
float_com32 分钟前
【java常用API】----- Arrays
java·开发语言
不会写DN1 小时前
PHP 中的文件读写与上传
android·开发语言·php
LuckyTHP2 小时前
迁移shibboleth java获取shibboleth用户信息
java·开发语言
客卿1232 小时前
数论===质数统计(暴力法,)
java·开发语言
华科易迅2 小时前
Spring 事务(注解)
java·数据库·spring
写代码的小阿帆2 小时前
Web工程结构解析:从MVC分层到DDD领域驱动
java·架构·mvc
东离与糖宝2 小时前
Java 26+Spring Boot 3.5,微服务启动从3秒压到0.8秒
java·人工智能