@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
相关推荐
一叶落43818 分钟前
LeetCode 54. 螺旋矩阵(C语言详解)——模拟 + 四边界收缩最初的↘那颗心21 分钟前
Prompt 工程实战:五要素框架与 Spring AI 模板化落地墨狂之逸才1 小时前
React Native 移动项目目录导致的 Android 编译失败问题及解决方案东离与糖宝1 小时前
Java 21 虚拟线程与 AI 推理结合的最新实践feng一样的男子1 小时前
住在手机里的“小龙虾” (OpenClaw):接入本地模型,解决记忆“装死”顽疾hongtianzai2 小时前
MySQL中between and的基本用法菜鸟小九2 小时前
hot100(71-80)大傻^2 小时前
LangChain4j 1.4.0 快速入门:JDK 11+ 基线迁移与首个 AI Service 构建代码探秘者2 小时前
【大模型应用】4.分块之六大策略