@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
相关推荐
小强库计算机毕业设计13 小时前
SpringBoot+Vue3 学生宿舍管理系统实战李冰然13 小时前
深入Java集合框架:HashMap源码解析(JDK 8)安卓与AI研习社13 小时前
Android ANR 到底怎么定位?从触发原理到日志判断的完整方法人道领域14 小时前
【0-1的agent进阶篇】RAG:从Embedding到检索增强生成的底层逻辑桦说编程14 小时前
盘点并发集合里那些容易误判的行为阿pin15 小时前
Android随笔-MVIleobertlan15 小时前
【好玩系列】训练一个神经网络指导小孩玩游戏IT爱学堂15 小时前
java版数据结构和算法+AI算法和技能学习指南Android-Flutter16 小时前
android LeakCanary 工作原理 详解evans在进步16 小时前
LeetCode 394:字符串解码——Java 单栈模拟与嵌套解析详解