Android doubletap, ontouchevent is not working

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 11:40:29

问题


I need to zoom when double tapping. Why doesn't this work? I worked on it for long time which has no result. No touch event is recognized

public class MyMapActivity extends MapActivity implements OnGestureListener{
private MapView mapView;

@Override
public void onCreate(Bundle savedInstanceState) {

requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView)findViewById(R.id.mapView);
mGestureDetector = new GestureDetector(this,this);
detector.setOnDoubleTapListener(new OnDoubleTapListener(){
    @Override
public boolean onDoubleTap(MotionEvent e) {
 int x = (int)e.getX(), y = (int)e.getY();;  
 Projection p = map.getProjection();  
 map.getController().animateTo(p.fromPixels(x, y));
 map.getController().zoomInFixing(x, y);  
 return false;
}

@Override
public boolean onDoubleTapEvent(MotionEvent e) {
    return false;
}

    });
}
@Override
public boolean onTouchEvent(MotionEvent me) {
this.mGestureDetector.onTouchEvent(me);
return super.onTouchEvent(me); 
}

回答1:


see this tutorial, it have the complete how to or see the similar questions on stackoverflow here and here.




回答2:


Try having a look at the MapView Ballons library which has support for double tapping to zoom and more! It is really good and easy to use and integrate with a project. MapView Ballons



来源:https://stackoverflow.com/questions/13106521/android-doubletap-ontouchevent-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!