1. Android Forums is going down for maintenance at 6:00PM Central time. We apologize for any inconvenience! Shouldn't be down too long.
  2. Check out our app, Forums for Android! Download and leave feedback here!

Spinner problem

Discussion in 'Application Development' started by Z!dd0, Jul 13, 2010.

  1. Z!dd0

    Z!dd0 New Member
    Thread Starter
    25

    Jul 13, 2010
    3
    0
    25
    Hi all!

    I want to use a Spinner (drop-down menu) in my page so the user can choose his gender: Mr, Mrs ou Ms
    When i launch my app, we see the spinner, with the word "Mr" (which is normal because it's the first choice).
    But when I click on it, the app crashes with that error message:

    Code (Text):
    1. 07-13 09:04:12.550: ERROR/AndroidRuntime(2773): Uncaught handler: thread main exiting due to uncaught exception
    2. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
    3. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewRoot.setView(ViewRoot.java:460)
    4. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
    5. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
    6. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.app.Dialog.show(Dialog.java:238)
    7. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
    8. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.widget.Spinner.performClick(Spinner.java:257)
    9. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.View.onTouchEvent(View.java:4133)
    10. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.View.dispatchTouchEvent(View.java:3672)
    11. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:850)
    12. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    13. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    14. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    15. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    16. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    17. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    18. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    19. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
    20. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1202)
    21. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.app.Activity.dispatchTouchEvent(Activity.java:1987)
    22. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
    23. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
    24. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.os.Handler.dispatchMessage(Handler.java:99)
    25. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.os.Looper.loop(Looper.java:123)
    26. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at android.app.ActivityThread.main(ActivityThread.java:4203)
    27. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at java.lang.reflect.Method.invokeNative(Native Method)
    28. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at java.lang.reflect.Method.invoke(Method.java:521)
    29. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
    30. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
    31. 07-13 09:04:12.560: ERROR/AndroidRuntime(2773):     at dalvik.system.NativeStart.main(Native Method)
    I searched on the internet and I found that this error is generic. Apparently it comes from the dialog created by the Spinner when i click on it...

    Anyone has an idea about that?

    Thank you by advance :)
     

    Advertisement

  2. Z!dd0

    Z!dd0 New Member
    Thread Starter
    25

    Jul 13, 2010
    3
    0
    25
    Code (Text):
    1.  
    2. ArrayAdapter<String> ad = new ArrayAdapter<String>(this.getContext(),android.R.layout.simple_spinner_item,items);
    3.          ad.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    4.          spinnerWidget.setAdapter(ad);
    5.  
    The problem comes here when I want to setAdapter
    I repared it by reinitializing the Spinner (new Spinner(context))
    But now I have this error:
    Code (Text):
    1. 07-15 09:10:50.365: ERROR/AndroidRuntime(573): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
    2.  
     

Share This Page

Loading...