java.lang.NoClassDefFoundError:com.example.samplemap.CustomItemizedOverlay

时间:2012-09-08 02:41:17

标签: java android google-maps

我正在Android google-map项目中使用mapviewballons,但我似乎遇到了上述问题。

09-08 02:15:11.792: E/AndroidRuntime(484): FATAL EXCEPTION: main
09-08 02:15:11.792: E/AndroidRuntime(484): java.lang.NoClassDefFoundError: com.example.samplemap.CustomItemizedOverlay

我已经梳理了代码,但我还没找到问题的确切来源。非常感谢你能帮助我解决这个问题的任何帮助。

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        final MapController mc = mapView.getController(); 
        mc.setZoom(16);

        List<Overlay> mapOverlays = mapView.getOverlays();
       // Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
        Drawable drawable = getResources().getDrawable(R.drawable.marker);
        CustomItemizedOverlay<CustomOverlayItem> itemizedoverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView);

        LocalGeoPoints loc = new LocalGeoPoints();
        for (CustomOverlayItem a : loc.overlayitems) {
            itemizedoverlay.addOverlay(a);
        } 
        mapOverlays.add(itemizedoverlay);


    }



public class CustomItemizedOverlay<Item extends OverlayItem> extends BalloonItemizedOverlay<CustomOverlayItem> {

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

    public CustomItemizedOverlay(Drawable defaultMarker, MapView mapView) {

        super(boundCenter(defaultMarker), mapView);
        c = mapView.getContext();
    }

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

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

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

    @Override
    protected boolean onBalloonTap(int index, CustomOverlayItem item) {
        Toast.makeText(c, "onBalloonTap for overlay index " + index,
                Toast.LENGTH_LONG).show();
        return true;
    }

    @Override
    protected BalloonOverlayView<CustomOverlayItem> createBalloonOverlayView() {
        // use our custom balloon view with our custom overlay item type:
        return new CustomBalloonOverlayView<CustomOverlayItem>(getMapView().getContext(), getBalloonBottomOffset());
    }

}

1 个答案:

答案 0 :(得分:0)

请将公共类CustomItemizedOverlay设为私有类