我有一個接收從服務器發送的地圖點的線程,並將這些點添加到MapView
。這工作正常,但如果我與MapView
交互(例如,放大,平移等),我得到ConcurrentModificationException
,所以我怎樣才能允許訪問用戶,而添加點MapView
?我如何將點添加到Google地圖視圖,同時仍允許用戶與地圖交互?
02-20 01:44:26.566: E/AndroidRuntime(9448): FATAL EXCEPTION: main
02-20 01:44:26.566: E/AndroidRuntime(9448): java.util.ConcurrentModificationException
02-20 01:44:26.566: E/AndroidRuntime(9448): at java.util.ArrayList$ArrayListIterator.next(ArrayList.java:569)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:41)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.google.android.maps.MapView.onDraw(MapView.java:532)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13707)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13591)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13589)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13589)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13589)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.View.draw(View.java:13710)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.widget.FrameLayout.draw(FrameLayout.java:467)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2211)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2281)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2177)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer.doFrame(Choreographer.java:532)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.os.Handler.handleCallback(Handler.java:725)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.os.Handler.dispatchMessage(Handler.java:92)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.os.Looper.loop(Looper.java:137)
02-20 01:44:26.566: E/AndroidRuntime(9448): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-20 01:44:26.566: E/AndroidRuntime(9448): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 01:44:26.566: E/AndroidRuntime(9448): at java.lang.reflect.Method.invoke(Method.java:511)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-20 01:44:26.566: E/AndroidRuntime(9448): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-20 01:44:26.566: E/AndroidRuntime(9448): at dalvik.system.NativeStart.main(Native Method)
謝謝,我曾經嘗試過,但也在那裏做網絡的東西,一旦我只是做UI的東西。 – 2013-02-20 02:52:02