首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

地图View双击事件监测

2012-09-01 
mapView双击事件监测public class MyMapView extends MapView {? private long lastTouchTime -1? publ

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);
? }

热点排行