@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);
}
android鼠标滚轮事件监听方法
王的备忘录2023-10-26 13:03
相关推荐
程序员码歌4 分钟前
短思考第268天,自媒体路上的4大坑点,很多人都踩过zs宝来了16 分钟前
ArrayList源码阅读brave_zhao33 分钟前
关于javafx下打开postman无法正常关闭postman的问题攻心的子乐36 分钟前
Spring IOC 源码Sirens.37 分钟前
Java异常处理解析:从防御式编程到自定义异常类千寻技术帮1 小时前
10351_基于Springboot的二手交易平台alonewolf_991 小时前
Spring依赖注入源码深度解析:从@Autowired到@Resource的完整实现机制雪碧聊技术1 小时前
如何界定人工智能和java开发二者的关系?Chase_______1 小时前
【JAVA基础指南(四)】快速掌握类和对象消失的旧时光-19431 小时前
从 Android 组件化到 Flutter 组件化