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);
    }
相关推荐
下地种菜小叶2 分钟前
特征定义、特征计算、特征服务怎么配合?一次讲透
java·服务器·前端·数据库·spring cloud
lifewange9 分钟前
Idea如何调大字体
java·macos·intellij-idea
许彰午12 分钟前
# 一个Java老鸟的TensorFlow入门——从计算图到GradientTape
java·tensorflow·neo4j
itzixiao13 分钟前
L1-055 谁是赢家(10 分)[java][python]
java·python·算法
IT利刃出鞘14 分钟前
Java反射--PropertyDescriptor的使用
java·开发语言
所愿ღ26 分钟前
SSM框架-Spring1
java·开发语言·笔记·spring
invicinble33 分钟前
对于泛型的设计思路
java
A_aspectJ42 分钟前
【Java基础开发】基于 Java Swing 开发的简易计算器 - 支持键盘
java·开发语言
2501_913061341 小时前
网络原理知识(7)
java·网络·面试
南境十里·墨染春水1 小时前
linux学习进程 线程同步——读写锁
java·jvm·学习