我有一个问题,那就是如何定义何时have移动动作,以及何时在MapView中简单地点击一个地理位置。事情是这样的,当我点击下面的evEnts就会出现: ACTION_DOWN(1个火灾),ACTION_MOVE(3个火灾),ACTION_DOWN(1个火灾)。当我移动以下事件时,appear:ACTION_DOWN(1个火灾),ACTION_MOVE(地块火灾),ACTION_DOWN(1个火灾)。
如何定义它,并且它不会阻塞onTap函数? alertDialog在哪里?
我做了什么,但我搞砸了一点:
@Override
protected boolean onTap(int index) {
Log.i("Tapped? ", "TAP!");
if (mOverlays.get(index) != null && !touchStarted) {
OverlayItem item = mOverlays.get(index);
alert.showAlertDialog(mContext, item.getTitle(), item.getSnippet(), true);
return true;
} else {
return false; // Null GeoPoint
}
}
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
Log.e("Touch", Integer.toString(event.getAction()));
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
touchStarted = true;
} else if (action == MotionEvent.ACTION_MOVE) {
// movement: cancel the touch press
touchStarted = false;
if (event.getPointerCount() > 3)
Log.e("Movement", "Yeee");
return true;
}
return true;
}发布于 2012-10-22 18:23:30
在您的活动中,实现用于查找点击事件的onDoubleTapListener,并且在onTouchEvent中,您将能够处理移动事件。使用switch case来检查移动和其他操作,而不是if语句,以提高性能
例如,如果abc是您的activity类,
public class abc extends Activity implements OnDoubleTapListener{
//Double tap listener
public boolean onSingleTapConfirmed(MotionEvent event) {
//your code
}
}https://stackoverflow.com/questions/13008957
复制相似问题