开发者

java.util.ConcurrentModificationException?

please guide what mistake am i doing here? any help would be appreciated.

private void LoopThroughEachATMToDisplayOnMap()
           {


               Drawable drawable = null;

                for (int i = 0; i < atm.getAtmList().size(); i++) {

                    if(breakFlag)
                        break;

                    drawable = getAppropriatePin(i);
                    if(drawable == null) 
                    drawable = getResources().getDrawable(R.drawable.marker);
                    itemizedOverlay = new MyItemizedOverlay(drawable, mapView);

                    ATM a = atm.getAtmList().get(i);
                    if (a != null) {
                        int[] coordinates = getIntCoordinates开发者_开发问答(a
                                .getCoordinates());
                        if (coordinates != null) {
                            GeoPoint point = new GeoPoint(coordinates[0],
                                    coordinates[1]);
                            OverlayItem overlayItem = new OverlayItem(
                                    point, a.getBankName(), a.getAddress()
                                            + "@@" + a.getPhone() + "@@"
                                            + a.getWebAddress() + "@@"
                                            + a.getCoordinates());
                            itemizedOverlay.addOverlay(overlayItem);
                            System.out
                                    .println("coordinates-------------------------"
                                            + i + " "
                                            + coordinates[0]
                                            + ","
                                            + coordinates[1]);
                        }

                    }
                    if(mapOverlays == null)
                        mapOverlays = mapView.getOverlays();

                    mapOverlays.add(itemizedOverlay);
                }
                System.out.println("atms maps injection complete--------------------------------");

           }    

    06-09 18:41:12.019: ERROR/AndroidRuntime(13973): Uncaught handler: thread main exiting due to uncaught exception
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973): java.util.ConcurrentModificationException
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at java.util.AbstractList$SimpleListIterator.next(AbstractList.java:64)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:44)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at com.google.android.maps.MapView.onDraw(MapView.java:494)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.View.draw(View.java:6535)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewGroup.drawChild(ViewGroup.java:1585)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1312)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.View.draw(View.java:6538)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewGroup.drawChild(ViewGroup.java:1585)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1312)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.View.draw(View.java:6538)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewGroup.drawChild(ViewGroup.java:1585)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1312)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.View.draw(View.java:6538)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.widget.FrameLayout.draw(FrameLayout.java:352)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1866)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewRoot.draw(ViewRoot.java:1364)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1118)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1650)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.os.Handler.dispatchMessage(Handler.java:99)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.os.Looper.loop(Looper.java:123)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at android.app.ActivityThread.main(ActivityThread.java:4595)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at java.lang.reflect.Method.invokeNative(Native Method)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at java.lang.reflect.Method.invoke(Method.java:521)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    06-09 18:41:12.149: ERROR/AndroidRuntime(13973):     at dalvik.system.NativeStart.main(Native Method)


i got answer my self.

actually mapOverlays.add(itemizedOverlay); needs ui to run.

so it was not ui thread thats why it was raising error.

i just ran that function in uithread and which resolved my problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜