Android 如果触摸一个记号笔3秒钟,该如何做
我有一个谷歌地图api v2的应用程序,上面有一些标记。对于每个标记,如果我点击它,它会显示一个气球,上面有一些关于它的详细信息,如标题等。 使用SystemClock,它只等待3秒钟,但它会执行操作 如果用户在该标记上按X秒,我想做些什么?我试着用一根线,但没有成功Android 如果触摸一个记号笔3秒钟,该如何做,android,timer,android-mapview,Android,Timer,Android Mapview,我有一个谷歌地图api v2的应用程序,上面有一些标记。对于每个标记,如果我点击它,它会显示一个气球,上面有一些关于它的详细信息,如标题等。 使用SystemClock,它只等待3秒钟,但它会执行操作 如果用户在该标记上按X秒,我想做些什么?我试着用一根线,但没有成功 if (onBalloonTap(currentFocusedIndex, currentFocusedItem)) { long thisTime = 0; thisTime =
if (onBalloonTap(currentFocusedIndex, currentFocusedItem)) {
long thisTime = 0;
thisTime = SystemClock.uptimeMillis();
if (thisTime > 3000) {
DirectionsTask getDirectionsTask = new DirectionsTask();
getDirectionsTask.execute(getCurrentLocation(),
currentFocusedItem.getPoint());
}
像这样的
GeoPoint p = null, currentP = null;
boolean isActivated = false;
view.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN) {
isActivated = false;
currentP = p ;
}
if(currentP == p && event.getEventTime()-event.getDownTime()>3000 && !) {
Toast.makeText(AudioPlayerActivity.this, "3 sec", Toast.LENGTH_LONG).show();
isActivated = true; //avoid displaying a lot of toast } return true; } });
}
if(event.getAction()==MotionEvent.ACTION_UP) {
currentP = null; p = null;
}
}
});
//extends Overlay type, works if the method is called when "action down"
public boolean onTap(GeoPoint p, MapView mapView) {
this.p = p;
return true;
}
是否可以在视图中添加OnTouchListener?like:`boolean isActivated=false;view.setOnTouchListener(新的OnTouchListener(){public boolean onTouch(view v,MotionEvent事件){if(event.getEventTime()-event.getDownTime()>3000&!已激活){Toast.makeText(AudioPlayerActivity.this,“3秒”,Toast.LENGTH_LONG).show();isActivated=true;//避免显示大量toast}返回true;})`我试图在itemizedoverlay中这样做。