@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
相关推荐
StarsGreen14 小时前
Android 12 中的“域“与“权限“介绍会编程的吕洞宾15 小时前
Spring AI 2.0 工具调用实战:让 AI 自动调用你的 Java 方法斯维赤16 小时前
SELECT * 为什么是覆盖索引的天敌?stormsha16 小时前
库存 5,10 个并发各买 1 件:为什么最后不剩 -5 件恋猫de小郭16 小时前
Android Keep Rules 解读,直接影响 Google Play 上架和曝光FlightYe16 小时前
音视频修炼之容器与协议(六):HTTP 协议RobinXYuan16 小时前
【Java 字节码探秘】02 ClassFile 骨架:十个字段炸薯条!16 小时前
Python面向对象基础:类与对象、实例方法、魔法方法和属性详解SimonKing17 小时前
又一款数据库同步神器,2.3K Star的dbswitchCoderYanger18 小时前
Java EE 进阶:11. SpringBoot 统一功能处理(第二弹):DispatcherServlet 源码分析+适配器模式