2011-09-12 37 views
1

我正在使用android 3.0拖放式框架。一切正常。但是在30個動作應用程序導致IllegalArgumentException之後。 dalvinkvm呼籲各的dragEventAndroid 3.0拖動n-drop IllegalArgumentException 30行動後

09-12 11:18:06.662: WARN/Surface(31132): Surface.finalize() has work. You should have called release() (1720472, 0) 

後,正如你所看到的異常和定稿之間的時間延遲大約爲30秒

09-12 11:17:32.282: WARN/Surface(31132): Not initializing the shared buffer client because token = -12 
09-12 11:17:32.282: ERROR/View(31132): Unable to initiate drag 
09-12 11:17:32.282: ERROR/View(31132): java.lang.IllegalArgumentException 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.Surface.lockCanvasNative(Native Method) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.Surface.lockCanvas(Surface.java:350) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.View.startDrag(View.java:11467) 
09-12 11:17:32.282: ERROR/View(31132):  at com.example.drag.drop.Dot$1.onTouch(Dot.java:70) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.View.dispatchTouchEvent(View.java:4605) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291) 
09-12 11:17:32.282: ERROR/View(31132):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709) 
09-12 11:17:32.282: ERROR/View(31132):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264) 
09-12 11:17:32.282: ERROR/View(31132):  at android.app.Activity.dispatchTouchEvent(Activity.java:2315) 
09-12 11:17:32.282: ERROR/View(31132):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.View.dispatchPointerEvent(View.java:4677) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392) 
09-12 11:17:32.282: ERROR/View(31132):  at android.view.ViewRoot.handleMessage(ViewRoot.java:2054) 
09-12 11:17:32.282: ERROR/View(31132):  at android.os.Handler.dispatchMessage(Handler.java:99) 
09-12 11:17:32.282: ERROR/View(31132):  at android.os.Looper.loop(Looper.java:132) 
09-12 11:17:32.282: ERROR/View(31132):  at android.app.ActivityThread.main(ActivityThread.java:4123) 
09-12 11:17:32.282: ERROR/View(31132):  at java.lang.reflect.Method.invokeNative(Native Method) 
09-12 11:17:32.282: ERROR/View(31132):  at java.lang.reflect.Method.invoke(Method.java:491) 
09-12 11:17:32.282: ERROR/View(31132):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 
09-12 11:17:32.282: ERROR/View(31132):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 
09-12 11:17:32.282: ERROR/View(31132):  at dalvik.system.NativeStart.main(Native Method) 
09-12 11:17:34.272: WARN/WindowManager(4050): Drag already in progress 
09-12 11:17:34.622: WARN/WindowManager(4050): Drag already in progress 
09-12 11:17:34.912: WARN/WindowManager(4050): Drag already in progress 
09-12 11:17:35.462: WARN/WindowManager(4050): Drag already in progress 
09-12 11:17:35.782: WARN/WindowManager(4050): Drag already in progress 
09-12 11:17:37.282: ERROR/WindowManager(4050): Unregister of nonexistent drag input channel 

申請再次工作正常。從書籍兩個示例項目發生

相同的異常:

1)http://www.manning.com/collins/;第15章示例:http://www.manning-sandbox.com/thread.jspa?messageID=117809&tstart=0

2)http://www.apress.com/9781430232223;例如在第31章

問:

1)如何正確地完成DragEvents?

2)如何調用Surface.finalize(),如果我用GridView控件,例如工作?

謝謝。

+0

我沒有解決此問題。發生此問題是因爲GC不執行拖動的收集。但是如果窗口重新顯示,GC會執行拖動的收集。打開軟鍵盤或更新一些ImageView或類似的東西后,窗口將被重新繪製。 –

回答

1

我一直在努力解決這個蜂窩問題好幾天,並找到了一條出路,儘管我不確定你的情況與我的相似。


在我的情況下,現在我可以肯定地說,「無法啓動拖動」消息是在對支持ListView的數據適配器進行更新開始的連鎖反應的末尾(我嘗試的項目以允許用戶拖放)。實際上,問題在於「Drop」,在那裏我會改變底層數據中的某些內容,並要求適配器通知DataSetChanged的ListView。

什麼爲我做的魔力,相當令人驚訝的,是代替每次調用:與

lv.getAdapter().notifyDataSetChanged(); 


resetListView(lv) 

定義爲:

private void resetListView(ListView lv) 
{ 
    int position = lv.getFirstVisiblePosition(); 
    int y = lv.getChildAt(0).getTop(); 
    lv.setAdapter(lv.getAdapter()); 
    lv.setSelectionFromTop(position, y); 
} 

類似notifyDataSetChanged(),此方法確保ListView使用l更新測試適配器數據,但此外,它還會重置ListView中的一些內部結構,從而防止後來的拖放式鏈反應導致上述異常。

生活與蜂窩並不容易。

+0

在我的情況下拖動啓動。但如果我試圖拖動30多次,我有這個例外。 –