【发布时间】:2012-04-02 05:19:14
【问题描述】:
我正在做一个项目,我想在单点触摸时显示一条特定消息,并使用 android 在双点触摸时显示另一条消息。我该如何实现它。
我的示例代码如下
if(firstTap){
thisTime = SystemClock.timeMillis();
firstTap = false;
}else{
prevTime = thisTime;
thisTime = SystemClock.uptimeMillis();
//Check that thisTime is greater than prevTime
//just incase system clock reset to zero
if(thisTime > prevTime){
//Check if times are within our max delay
if((thisTime - prevTime) <= DOUBLE_CLICK_MAX_DELAY){
//We have detected a double tap!
Toast.makeText(AddLocation.this, "DOUBLE TAP DETECTED!!!", Toast.LENGTH_LONG).show();
//PUT YOUR LOGIC HERE!!!!
}else{
//Otherwise Reset firstTap
firstTap = true;
}
}else{
firstTap = true;
}
}
return false;
【问题讨论】:
-
您是否考虑过使用长按来替代双击?
-
看这个(在Android中实现双击按钮)[stackoverflow.com/questions/4849115/…
-
请遵循android使用模式并使用长按。不要双击。
-
只是想帮忙,我发布一个答案[这里][1] [1]:stackoverflow.com/questions/20595003/…
-
我在 [这里][1] 发布了一个答案。只是想帮忙。 :D [1]: stackoverflow.com/questions/20595003/…
标签: android