I pull out my hair, trying to get this seemingly simple task to work. I need to put an animated gif in an overlay on the map.
I have the following code:
AnimationDrawable anim = (AnimationDrawable)getResources().getDrawable(R.drawable.explosion);
How do I now put this in the overlay and throw it on the card?
Currently for still images I have this:
class DrawableIcon extends ItemizedOverlay { private ArrayList mOverlays = new ArrayList(); public DrawableIcon(Drawable defaultMarker) { super(boundCenterBottom(defaultMarker)); } public void addOverlay(OverlayItem overlay) { mOverlays.add(overlay); populate(); } @Override protected OverlayItem createItem(int i) { return mOverlays.get(i); } @Override public int size() { return mOverlays.size(); } }
class DrawableIcon extends ItemizedOverlay { private ArrayList mOverlays = new ArrayList(); public DrawableIcon(Drawable defaultMarker) { super(boundCenterBottom(defaultMarker)); } public void addOverlay(OverlayItem overlay) { mOverlays.add(overlay); populate(); } @Override protected OverlayItem createItem(int i) { return mOverlays.get(i); } @Override public int size() { return mOverlays.size(); } }
which I then use as such: (gp is the geometry of the spot in which I want to put the image)
DrawableIcon image = new DrawableIcon(this.getResources().getDrawable(ResourceID)); image.addOverlay(new OverlayItem(gp, "", "")); mapOverlays.add(image);
DrawableIcon image = new DrawableIcon(this.getResources().getDrawable(ResourceID)); image.addOverlay(new OverlayItem(gp, "", "")); mapOverlays.add(image);
So, how can I change this code so that when the ResourceID is the identifier of the animated gif, the gif will play its animation over mapview?
Thanks in advance!
source share