我正在尝试创建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