1

我有一个带有 google maps api v2 的应用程序,上面有一些标记。对于每个标记,如果我单击它,它会出现一个带有一些关于它的标题等详细信息的气球。使用 SystemClock 它只等待 3 秒,但它会执行操作。

如果用户在该标记上按下 X 秒,我想做些什么?我尝试使用线程,但没有成功。

if (onBalloonTap(currentFocusedIndex, currentFocusedItem)) {
            long thisTime = 0;
            thisTime = SystemClock.uptimeMillis();
            if (thisTime > 3000) {

                DirectionsTask getDirectionsTask = new DirectionsTask();
                getDirectionsTask.execute(getCurrentLocation(),
                        currentFocusedItem.getPoint());
            }
4

1 回答 1

0

类似的东西?

    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;
     }
于 2013-02-25T15:43:48.167 回答