gpt4 book ai didi

30 次操作后的 Android 3.0 拖放 IllegalArgumentException

转载 作者:行者123 更新时间:2023-11-30 04:32:52 27 4
gpt4 key购买 nike

我正在使用 android 3.0 拖放框架。一切正常。但是在 30 个操作之后,应用程序会导致 IllegalArgumentException。

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

在 dalvinkvm 调用每个 DragEvent 后,应用程序再次正常工作

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

如您所见,异常和完成之间的时间延迟大约为 30 秒。

书中的两个示例项目发生了同样的异常:

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)如果我正在使用 GridView,如何调用 Surface.finalize()?

谢谢。

最佳答案

我已经为这个 Honeycomb 错误苦苦挣扎了好几天,并找到了解决方法,尽管我不确定您的情况是否与我相似。

就我而言,现在我可以肯定地说,“无法启动拖动”消息是在对支持 ListView 的数据适配器进行更新开始的链式 react 结束时出现的(我试图允许用户使用其项目拖放)。事实上,问题在于“Drop”,我会在其中更改基础数据中的某些内容并要求适配器通知 ListView DataSetChanged。

对我来说神奇的是,令人惊讶的是,替换了对以下内容的每次调用:

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更新为最新的adapter-data,但除此之外,它还重置了ListView内部的一些内部结构,防止了后面的拖放链式 react 导致上述异常。

与 Honeycomb 一起生活并不容易。

关于30 次操作后的 Android 3.0 拖放 IllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7385536/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com