@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
相关推荐
Wang's Blog1 小时前
Java 项目实战: 外卖平台优化-Nginx配置文件结构与块层级\光辉岁月/3 小时前
5.java-数组谢亮_vipxieliang3 小时前
Spring 事务失效的常见场景郑州光合科技余经理3 小时前
海外版外卖加盟:总站与分站配送规则怎么分开管2601_962071573 小时前
类变量和全局变量的生命周期有什么区别?code2cat3 小时前
Java进阶篇之AtomicReference:一次替换引用,读到一份完整状态专业程序开发源4 小时前
springboot简历管理系统81389-计算机课程设计、毕业设计Wang's Blog4 小时前
Java 项目实战: 外卖平台优化-前后端分离开发模式与工程拆分HEJOO95 小时前
指针的算术运算详解sunshine22 girl5 小时前
Java学习六 Java常见API-2--String-3-字符串的截取替换和其他方法