点击(此处)折叠或打开

  1. 10-21 08:39:12.314: E/AndroidRuntime(969): FATAL EXCEPTION: main
  2. 10-21 08:39:12.314: E/AndroidRuntime(969): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@40519318 is not valid; is your activity running?
  3. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.view.ViewRoot.setView(ViewRoot.java:527)
  4. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
  5. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
  6. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.view.Window$LocalWindowManager.addView(Window.java:424)
  7. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.app.Dialog.show(Dialog.java:241)
  8. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
  9. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.widget.Spinner.performClick(Spinner.java:260)
  10. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.view.View$PerformClick.run(View.java:9080)
  11. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.os.Handler.handleCallback(Handler.java:587)
  12. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.os.Handler.dispatchMessage(Handler.java:92)
  13. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.os.Looper.loop(Looper.java:123)
  14. 10-21 08:39:12.314: E/AndroidRuntime(969): at android.app.ActivityThread.main(ActivityThread.java:3683)
  15. 10-21 08:39:12.314: E/AndroidRuntime(969): at java.lang.reflect.Method.invokeNative(Native Method)
  16. 10-21 08:39:12.314: E/AndroidRuntime(969): at java.lang.reflect.Method.invoke(Method.java:507)
  17. 10-21 08:39:12.314: E/AndroidRuntime(969): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  18. 10-21 08:39:12.314: E/AndroidRuntime(969): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  19. 10-21 08:39:12.314: E/AndroidRuntime(969): at dalvik.system.NativeStart.main(Native Method)
BAIDU后发现是不能直接

点击(此处)折叠或打开

  1. setContentView(R.layout.XX);
而应该使用:


点击(此处)折叠或打开

  1. View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.XX, null);
  2. this.setContentView(viewToLoad)

Android的两层TAB嵌套有好多问题啊。期待GOOGLE能解决一下。

10-30 00:24