when I run my project with the Commonsware TouchListView inside a TabGroupActivity, I can see the ListView but when I try to Drag an item the app crashes. I have this in the log :
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)
I do not support activities-in-tabs for any of the CWAC components. It is an officially deprecated technique. It was never a very good idea in the first place, IMHO.
The TouchListView
code comes from an Android open source application that does not use tabs in the activity with the drag-and-drop. The technique it uses for the drag indicator -- adding it as a view to the Window
-- probably does not work for activities-in-tabs. It may work if you set up your tabs to have views as their contents, as you can see in this sample project.