Created
November 29, 2012 13:28
-
-
Save ilguzin/4169068 to your computer and use it in GitHub Desktop.
Simple way of making long tap event work in MapView. MapActivity class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyMapActivity extends MapActivity | |
implements OnGestureListener { | |
... | |
private GestureDetector gestureDetector; | |
@Override | |
public void onCreate(...) { | |
super.onCreate(...); | |
setContentView(R.layout.mymapviewlayout); | |
this.gestureDetector = new GestureDetector(this); | |
this.gestureDetector.setIsLongpressEnabled(true); | |
this.mapView = (MapView)findViewById(R.id.myMapView); | |
this.mapView.set.... | |
... | |
this.mapView.setClickable(true); | |
... | |
} | |
@Override | |
public boolean dispatchTouchEvent(MotionEvent ev) { | |
int actionType = ev.getAction(); | |
switch (actionType) { | |
case MotionEvent.ACTION_MOVE: | |
//react properly | |
break; | |
} | |
return gestureDetector.onTouchEvent(ev); | |
} | |
... | |
//other methods of the OnGestureListener interface | |
public void onLongPress(MotionEvent e) { | |
ActivityUtils.showToast(this, "Pushed down", 3000); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment