Java Android绑定不匹配

时间:2012-09-17 17:32:01

标签: java android

我仍然是Java的新手,我正在尝试使用该地址的代码。 http://proyectouvipool.googlecode.com/svn-history/r87/trunk/Android/PFC/src/pablo/developer/BalloonItemizedOverlay.java

不幸的是,我收到以下错误消息

绑定不匹配:类型Item不是BalloonOverlayView类型的有界参数的有效替代

代码

protected BalloonOverlayView<Item> createBalloonOverlayView() {
      return new BalloonOverlayView<Item>(getMapView().getContext(), getBalloonBottomOffset());
     }

会对如何解决这个问题感谢一些帮助吗?

1 个答案:

答案 0 :(得分:0)

public class CustomBalloonItemizedOverlay extends
            BalloonItemizedOverlay<OverlayItem> {

        private ArrayList<OverlayItem> m_overlays = new ArrayList<OverlayItem>();
        private Context c;

        public MyFavoritePlacesItemizedOverlay(Drawable defaultMarker,
                MapView mapView) {
            super(boundCenter(defaultMarker), mapView);
            c = mapView.getContext();
        }

        public void addOverlay(OverlayItem overlay) {
            m_overlays.add(overlay);
            populate();
        }

        @Override
        public void draw(Canvas canvas, MapView mapView, boolean shadow) {
            if (!shadow) {
                super.draw(canvas, mapView, false);
            }
        }

        public void removeOverlay(OverlayItem overlay) {
            m_overlays.remove(overlay);
            populate();
        }

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

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

        @Override
        protected boolean onBalloonTap(int index, OverlayItem item) {
            // Your code... 
            return true;
        }
    }

以下是如何使用...

initGeoPoint = new GeoPoint((int)(纬度* 1E6),                         (int)(经度* 1E6));

            mapOverlays = myMapView.getOverlays();
drawableImage = this.getResources().getDrawable(R.drawable.any_icon);

CustomBalloonItemizedOverlay customItemizedOverlayObject = new public class CustomBalloonItemizedOverlay(
                    drawableImage, myMapView);
            OverlayItem overlayItem = new OverlayItem(initGeoPoint, name,
                    address);

            customItemizedOverlayObject.addOverlay(overlayItem);
            mapOverlays.add(customItemizedOverlayObject);

        }