JoshKraker
Newbie
Hello everyone! Hopefully I can get some help here; the google group does not seem very helpful. I'm a beginner to the Android SDK as well as java for that fact (VB.NET background).
I have a map with some geometry drawn on it by overriding the onDraw event. I'm trying to detect when the user touches on of the shapes and attempting this with the following code
Ok so when the screen is touched, it will pass the coordinates into the Geo class and look for an object that contains those coordinates. If the touch was within the object, then I will do some processing and return true so the event is not passed down the the map. If the touch is not in the object then the event is passed down to the map as normal so the user can scroll and such.
If they touch an object everything is fine, they can keep touching more and I keep getting the event. The problem is when its not on an object. I'll get the first ACTION_DOWN, ACTION_MOVE, and ACTION_UP but no more events after that hit the onTouch handler.
What am I doing wrong?
I have a map with some geometry drawn on it by overriding the onDraw event. I'm trying to detect when the user touches on of the shapes and attempting this with the following code
Code:
public class Map extends MapActivity implements OnTouchListener {
public MapView _mvMap;
private Geo.Geometry _oGeo;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
_mvMap = (MapView) findViewById(R.id.mvMap);
_oGeo = new Geo().new Geometry(_mvMap);
_mvMap.getOverlays().add(_oGeo);
_mvMap.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent event) {
int Action = event.getAction();
Geo.Geometry Geo = _oGeo.SetTouched((int)event.getX(), (int)event.getY());
switch (Action) {
case MotionEvent.ACTION_UP:
if (Geo != null) {
//Do Some Processing
}
}
if (Geo != null) return true;
v.onTouchEvent(event);
v.setOnTouchListener(this);
return true;
}
If they touch an object everything is fine, they can keep touching more and I keep getting the event. The problem is when its not on an object. I'll get the first ACTION_DOWN, ACTION_MOVE, and ACTION_UP but no more events after that hit the onTouch handler.
What am I doing wrong?