so I’m facing an issue here that I’m sure many a developer before me has faced as well. I have my MapActivity class which creates an ItemizedOverlay class. The ItemizedOverlay has a OnTap even. When this OnTap event is fired I need to find a way to start an event in MapActivity class. It’s really quite simple.
So in More details I have:
public class Map extends MapActivity {
private MapItemizedOverlay itemizedOverlay;
@Override
public void onCreate(Bundle savedInstanceState) {
itemizedOverlay = new MapItemizedOverlay();
}
}
public class MapItemizedOverlay extends ItemizedOverlay<OverlayItem> {
public MapItemizedOverlay() {
}
@Override
protected synchronized boolean onTap(int index) {
// I need to find a way to tell the instantiating class this happened!
}
}
I realize I can do things like use static variables, timers, and things like that, but they just don’t seem like the best solution.
Option #1: Make the
ItemizedOverlaybe an inner class of theMapActivity, in which case you just call a method.Option #2: Pass the
MapActivityinto theItemizedOverlay(constructor or setter), in which case you just call a method on the activity.BTW,
onTap()will be called on the main application thread, so it is unlikely that you will needsynchronized.