@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
相关推荐
studyForMokey6 小时前
【Android 面试】Paging3企业数字化笔记6 小时前
租户停用后数据和任务怎么处理?冻结、恢复与保留策略的实现CarIise6 小时前
Spring MVC 请求参数绑定与常用注解一条泥憨鱼7 小时前
AI Agent 安全实践:从 MCP 工具调用到 Java 权限校验Nebula_g7 小时前
云禾外卖补充—项目整体后端运行逻辑-对流程的更深层次理解萧瑟余晖7 小时前
Spring Security 6.x新特性与架构演进详解\光辉岁月/7 小时前
1.Object类鸽鸽程序猿7 小时前
【项目】【在线判题系统】公共功能一只笨菜鸟7 小时前
IDEA如何让多个项目同时显示G018_star sky♬7 小时前
java中的字符串常见方法