2

ActivityGroup在某个选项卡上实现了。其中一个屏幕ActivityGroup是 aPreferenceScreen并且由 a 组成ListPreference

单击时ListPreference会引发异常,并且无法加载对话框。这是异常的完整堆栈跟踪:-

05-08 12:05:31.545: E/AndroidRuntime(247): Uncaught handler: thread main exiting due to uncaught exception
05-08 12:05:31.585: E/AndroidRuntime(247):  android.view.WindowManager$BadTokenException: Unable to add window -- token    android.app.LocalActivityManager$LocalActivityRecord@44ec8ac8 is not valid; is your activity running?
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.view.ViewRoot.setView(ViewRoot.java:468)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.view.Window$LocalWindowManager.addView(Window.java:424)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.app.Dialog.show(Dialog.java:239)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.preference.DialogPreference.showDialog(DialogPreference.java:307)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.preference.DialogPreference.onClick(DialogPreference.java:265)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.preference.Preference.performClick(Preference.java:811)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:190)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.widget.ListView.performItemClick(ListView.java:3285)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1640)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.os.Handler.handleCallback(Handler.java:587)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.os.Looper.loop(Looper.java:123)
05-08 12:05:31.585: E/AndroidRuntime(247):  at android.app.ActivityThread.main(ActivityThread.java:4363)
05-08 12:05:31.585: E/AndroidRuntime(247):  at java.lang.reflect.Method.invokeNative(Native Method)
05-08 12:05:31.585: E/AndroidRuntime(247):  at java.lang.reflect.Method.invoke(Method.java:521)
05-08 12:05:31.585: E/AndroidRuntime(247):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-08 12:05:31.585: E/AndroidRuntime(247):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-08 12:05:31.585: E/AndroidRuntime(247):  at dalvik.system.NativeStart.main(Native Method)

我还尝试实现 DialogPreference 而不是 ListPreference,但它仍然以相同的方式崩溃。

在添加ActivityActivityGroup.

4

1 回答 1

1

通过将父级的上下文设置为 listpreference 解决了这个问题。

谢谢。

于 2012-09-27T12:12:19.750 回答