读书人

地图View双击事件监测

发布时间: 2012-09-01 09:33:02 作者: rapoo

mapView双击事件监测

public class MyMapView extends MapView {

? private long lastTouchTime = -1;

? public MyMapView(Context context, AttributeSet attrs) {

??? super(context, attrs);
? }

? @Override
? public boolean onInterceptTouchEvent(MotionEvent ev) {

??? if (ev.getAction() == MotionEvent.ACTION_DOWN) {

????? long thisTime = System.currentTimeMillis();
????? if (thisTime - lastTouchTime < 250) {

??????? // Double tap
??????? this.getController().zoomInFixing((int) ev.getX(), (int) ev.getY());
??????? lastTouchTime = -1;

????? } else {

??????? // Too slow 地图View双击事件监测
??????? lastTouchTime = thisTime;
????? }
??? }

??? return super.onInterceptTouchEvent(ev);
? }

读书人网 >移动开发

热点推荐