I'm working on an Android class that extends MapActivity. I have set the OnTouchListener and everything works okay for the first MotionEvent. After the first MotionEvent, the system stops either generating MotionEvents or receiving them or both. Does anybody know what I have to do to keep receiving MotionEvents? Thanks.
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setOnTouchListener(new View.OnTouchListener( ) {
@Override public boolean onTouch(View v, MotionEvent event) {
Log.i(TAG, "onTouch called");
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.i(TAG, "ACTION_DOWN: x = " + event.getX() + ", y = " + event.getY());
break;
case MotionEvent.ACTION_UP:
Log.i(TAG, "ACTION_UP: x = " + event.getX() + ", y = " + event.getY());
break;
case MotionEvent.ACTION_CANCEL:
Log.i(TAG, "ACTION_CANCEL: x = " + event.getX() + ", y = " + event.getY());
break;
case MotionEvent.ACTION_OUTSIDE:
Log.i(TAG, "ACTION_OUTSIDE: x = " + event.getX() + ", y = " + event.getY());
break;
case MotionEvent.ACTION_MOVE:
Log.i(TAG, "ACTION_MOVE: x = " + event.getX() + ", y = " + event.getY());
break;
}
v.onTouchEvent(event);
return true; // I also tried return false here, that didn't fix anything
}
});