我正在嘗試創建MapView
的擴展版本。Android Custom MapView
問題是當定義了擴展版本MapView
時,mapview不能平移。
我正在執行onTouchListener
在我的自定義地圖視圖中。
我也想知道是否有任何方法可以從我可以平移mapview。
使用相同的源代碼使用股票版本的MapView時,問題不會持續存在。
編輯
MyMapView來源:
public class MyMapView extends MapView{
public MyMapView(Context context, String apiKey) {
super(context, apiKey);
}
public MyMapView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyMapView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN){
Log.v("MyMapView","Touched");
}
return false ;
}
}
我onCreate()
從MapActivity
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.mapper);
mMapView=(MyMapView) findViewById(R.id.mapper_map);
mMapView.setSatellite(false);
}
我懷疑這可能是因爲你從一些onTouch方法返回true - 嘗試返回false;這應該允許你的類做一些事情,然後讓觸摸事件傳播到基類來做它的東西。但讓我們看看你的代碼。 – 2011-01-12 12:54:23
@ John J Smith,代碼在帖子中更新。 – Shardul 2011-01-13 06:55:43