我有一个地图视图,可以在其中添加图钉。
这是 CustomPinPoint 类:
public class CustomPinpoint extends ItemizedOverlay<OverlayItem>{
private ArrayList<OverlayItem> pinpoints = new ArrayList<OverlayItem>();
private Context c;
public CustomPinpoint(Drawable defaultMarker) {
super(boundCenter(defaultMarker));
// TODO Auto-generated constructor stub
}
public CustomPinpoint(Drawable m, Context context) {
// TODO Auto-generated constructor stub
this(m);
c = context;
}
@Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return pinpoints.get(i);
}
@Override
public int size() {
// TODO Auto-generated method stub
return pinpoints.size();
}
public void insertPinpoint(OverlayItem item){
pinpoints.add(item);
this.populate();
}
}
这就是我添加引脚的方式:
Touchy t = new Touchy();
overlayList = map.getOverlays();
overlayList.add(t);
compass = new MyLocationOverlay(Map.this, map);
overlayList.add(compass);
controller = map.getController();
OverlayItem overlayItem = new OverlayItem(ourLocation, "What's up", "2nd String");
CustomPinpoint custom = new CustomPinpoint(d, Map.this);
custom.insertPinpoint(overlayItem);
overlayList.add(custom);
一切都很好,但我不知道当我点击图钉时如何让气球(或其他类)出现。我有一个包含每个引脚描述的数据库,因此我需要为每次单击引脚显示描述。