当我在TabGroupActivity中使用Commonsware TouchListView运行我的项目时,我可以看到ListView,但是当我尝试拖动项目时,应用程序崩溃了。我在日志中有这个:
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): FATAL EXCEPTION: main
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4099bfd0 is not valid; is your activity running?
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewRoot.setView(ViewRoot.java:527)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.Window$LocalWindowManager.addView(Window.java:424)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.commonsware.cwac.tlv.TouchListView.startDragging(TouchListView.java:419)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.commonsware.cwac.tlv.TouchListView.onInterceptTouchEvent(TouchListView.java:176)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:848)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.os.Handler.dispatchMessage(Handler.java:99)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.os.Looper.loop(Looper.java:130)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at java.lang.reflect.Method.invokeNative(Native Method)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at java.lang.reflect.Method.invoke(Method.java:507)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-21 11:21:50.433: ERROR/AndroidRuntime(23139): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
我不支持任何CWAC组件的活动标签。这是一种官方弃用的技术。首先,恕我直言,这绝不是一个好主意。
TouchListView
代码来自Android开源应用程序,该应用程序不通过拖放操作使用活动中的选项卡。它用于拖动指示器的技术 - 将其作为视图添加到Window
- 可能不适用于标签中的活动。如果您设置标签以将视图作为其内容,则可能会有效,如this sample project中所示。