@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
相关推荐
hunterandroid4 小时前
Android 多渠道打包与 Gradle 构建优化实战Zane19944 小时前
自己写一个 java.lang.String,为什么永远替换不掉 JDK 那个小白羊丨4 小时前
异步任务创建接口如何幂等?吴声子夜歌4 小时前
Guava——并发(一)天空属于哈夫克34 小时前
企业微信API:企业微信如何实现自动化运营?lhldsg4 小时前
相册印刷实战指南:从设计规范到系统落地全流程解析vipxieliang4 小时前
订单数据验证:从购物车到支付的完整验证链路草青工作室4 小时前
java-不携带Token也能“打“自己的接口:一个绕开网关鉴权、用 URL 直接调度 SpringMVC 方法的轻量级定时任务方案用户0934077735144 小时前
HarmonyOS WPS Open SDK 实践:把水印与修订收成打开策略层sumatch4 小时前
ESP32