gpt4 book ai didi

android - 如何获取 android Activity 或控制触摸计数?

转载 作者:行者123 更新时间:2023-11-29 21:15:55 24 4
gpt4 key购买 nike

我想获取 Activity 或任何控制元素的触摸计数。像 Android 4.2 on nexus Developer options Enable while touch 7 times.

处理它的合适事件是什么?

最佳答案

你得到 2 个计数,因为每次触摸事件被调用时都会调用触摸事件,比如向下和向上(例如)

    @Override
public boolean onTouchEvent(MotionEvent event) {
int action = MotionEventCompat.getActionMasked(event);
switch (action) {
case MotionEvent.ACTION_DOWN:
//add here the counter if you want when screen pressed
break;
case MotionEvent.ACTION_UP:
//add here the counter if you want when touch released
break;
default:
return super.onTouchEvent(event);
}
}

关于android - 如何获取 android Activity 或控制触摸计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21466984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com