Note that there are some explanatory texts on larger screens.

plurals
  1. POSpinner dynamic error
    text
    copied!<p>I have an error in my app for Android. I have a class <code>LineaArticulo</code> dynamics to form a line with labels, edit text, a button and spinner, to tighten the spinner I get an error, attached here the class constructor.</p> <p>All data is the correct.</p> <p>Here just put the spinner case.</p> <pre><code>public LineaArticulo(RelativeLayout layoutactual, final String[] Casos, Context context, int Xspinner, int Yspinner){ final Spinner spiner = new Spinner(context); ArrayAdapter&lt;String&gt; adaptador = new ArrayAdapter&lt;String&gt;(context, android.R.layout.simple_spinner_item, Casos); adaptador.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); spiner.setAdapter(adaptador); RelativeLayout.LayoutParams paramSpiner = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); paramSpiner.leftMargin = Xspinner; // Your X coordinate paramSpiner.topMargin = Yspinner; // Your Y coordinate spiner.setLayoutParams(paramSpiner); layoutactual.addView(spiner); } </code></pre> <p>Error: </p> <pre><code> 06-04 16:02:02.021 961-961/compra.online.mercavalencia E/AndroidRuntime: FATAL EXCEPTION: main android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application at android.view.ViewRoot.setView(ViewRoot.java:531) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) at android.app.Dialog.show(Dialog.java:241) at android.app.AlertDialog$Builder.show(AlertDialog.java:802) at android.widget.Spinner.performClick(Spinner.java:260) at android.view.View$PerformClick.run(View.java:9080) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload