ItemizedOverlay削除{{ItemizedOverlay:さくじょ}}

1381 ワード

地図にアイコンを追加して削除したいのですが、削除して元の座標をクリックしても実行されます
public class MyItemOverlay extends ItemizedOverlay<OverlayItem> {
	private ArrayList<OverlayItem> overlays = new ArrayList<OverlayItem>();
	private Context context;

	public ArtItemOverlay(Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker));
	}

	public ArtItemOverlay(Drawable defaultMarker, Context context) {
		this(defaultMarker);
		this.context = context;
	}

	@Override
	protected OverlayItem createItem(int i) {
		return overlays.get(i);
	}

	@Override
	public int size() {
		return overlays.size();
	}

	@Override
	protected boolean onTap(int index) {
		OverlayItem item = overlays.get(index);
		AlertDialog.Builder dialog = new AlertDialog.Builder(context);
		dialog.setTitle(item.getTitle());
		dialog.setMessage(item.getSnippet());
		dialog.show();
		return true;
	}

	public void addOverlay(OverlayItem overlay) {
		overlays.add(overlay);
	}
	
	public void removeOverlay(OverlayItem overay){
		overlays.remove(overay);
	}
	
	public void doPopulate(){
		populate();
	}
}

そして実行
"setLastFocusedIndex(-1);"「doPopulate()」.