2013-01-19 54 views

回答

1

所有交互我已經找到了解決辦法。您需要通過設置OnTouchListener直接處理觸摸事件。例如,

public class MapViewLayout extends RelativeLayout { 

    private MapView mapView; 

    /** 
    * @see #setDetachedMode(boolean) 
    */ 
    private boolean detachedMode; 

    // implement initialization of your layout... 

    private void setUpMapView() { 
     mapView.setOnTouchListener(new OnTouchListener() { 
      @Override 
      public boolean onTouch(View v, MotionEvent event) { 
       if (detachedMode) { 
        if (event.getAction() == MotionEvent.ACTION_UP) { 
         // if you want to fire another event 
        } 

        // Is detached mode is active all other touch handler 
        // should not be invoked, so just return true 
        return true; 
       } 

       return false; 
      } 
     }); 
    } 

    /** 
    * Sets the detached mode. In detached mode no interactions will be passed to the map, the map 
    * will be static (no movement, no zooming, etc). 
    * 
    * @param detachedMode 
    */ 
    public void setDetachedMode(boolean detachedMode) { 
     this.detachedMode = detachedMode; 
    } 
} 
1

你可以嘗試:

mapView.setEnabled(false); 

哪些應該禁用與地圖視圖

+1

感謝這個建議,但它不適合我。 – dominik

1

一個簡單的解決方案是不喜歡@Schrieveslaach但的MapView:

mapView.setOnTouchListener(new View.OnTouchListener() { 
    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     return true; 
    } 
});