Android Maps NullPointerException ItemizedOverlay

这根本不涉及我的代码中的任何地方.我该如何走到最底层?

java.lang.NullPointerException
at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42)
at com.google.android.maps.MapView.onDraw(MapView.java:494)
at android.view.View.draw(View.java:6739)
at android.view.ViewGroup.drawChild(ViewGroup.java:1648)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
at android.view.View.draw(View.java:6742)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at android.view.ViewGroup.drawChild(ViewGroup.java:1648)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
at android.view.View.draw(View.java:6742)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1872)
at android.view.ViewRoot.draw(ViewRoot.java:1422)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1167)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

这是ItemizedOverlay的draw方法

public void draw(Canvas canvas, MapView mapView, boolean shadow) {

            try {
            super.draw(canvas, mapView, false);

            if (getMainOverlayArray().size() != 0){

            pfOverlayItem tempOver = null;
            for (int i = 0; i < getMainOverlayArray().size(); i++) {

                tempOver = getMainOverlayArray().get(i);

            boolean isMatch = false;

            if (tempOver.getTitle().equals(selectedName))
            {
                isMatch = true;
            }

            if (isMatch){

            Projection projection = mapView.getProjection();
            Point point = new Point();
            projection.toPixels(tempOver.getPoint(), point);

            Paint background = new Paint();
            background.setColor(Color.WHITE);
            background.setAlpha(150);
            RectF rect = new RectF();
            rect.set(point.x - 55, point.y +15,
                    point.x + 100, point.y + 65);
            canvas.drawRoundRect(rect, 5, 5, background);


            Paint text = new Paint();
            text.setAntiAlias(true);
            text.setColor(Color.BLUE);
            text.setTextSize(14);
            text.setTypeface(Typeface.MONOSPACE);

            canvas.drawText(tempOver.getTitle() , point.x -50 , point.y + 30, text);
            canvas.drawText(tempOver.getTypeTextOut(), point.x -50 , point.y + 45, text);
            canvas.drawText(tempOver.getdestination(), point.x -50 , point.y + 60, text);
            }
            }
            }
            }catch (Exception e){
                Log.e("Error", "Problem drawing view", e);
                e.printStackTrace();
            }
        }

我现在打印出栈跟踪,没有区别!

上一篇:javascript – Jquery UI模式对话框


下一篇:C#拖放效果与叠加/不透明图像