本文介绍了Android的doubletap,ontouchevent不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要放大时,双攻。为什么没有这方面的工作?我曾在它里面有没有结果很长一段时间。没有触摸事件被认为是

 公共类MyMapActivity扩展MapActivity实现OnGestureListener {
私人MapView类MapView类;@覆盖
公共无效的onCreate(捆绑savedInstanceState){requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
图形页面=(图形页面)findViewById(R.id.mapView);
mGestureDetector =新GestureDetector(这一点,这一点);
detector.setOnDoubleTapListener(新OnDoubleTapListener(){
    @覆盖
公共布尔onDoubleTap(MotionEvent五){
 INT X =(INT)e.getX(),Y =(INT)e.getY();;
 投影p值= map.getProjection();
 。map.getController()animateTo(p.fromPixels(X,Y));
 。map.getController()zoomInFixing(X,Y);
 返回false;
}@覆盖
公共布尔onDoubleTapEvent(MotionEvent五){
    返回false;
}    });
}
@覆盖
公共布尔onTouchEvent(MotionEvent我){
this.mGestureDetector.onTouchEvent(箱);
返回super.onTouchEvent(箱);
}


解决方案

尝试在看看在 MapView的气球库,它有双点击缩放和更多的支持!这是非常好,易于使用,并与项目相结合。

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);
}
解决方案

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

这篇关于Android的doubletap,ontouchevent不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:19