Note that there are some explanatory texts on larger screens.

plurals
  1. POError spinner in popup window when I click
    text
    copied!<p>My app if poulsas a button a pop-out which has two spinners, well then I get the pop-up there all right but when I get the error is when I click on the spinner.</p> <p>Here you have my below code and debug, because logcat I get everything right.</p> <pre><code> public void añadirRegistro(View v){ showPopup(leer_registros.this); } private void showPopup(final Activity context) { Spinner eleccionIP,eleccionRegistro; borrar_datos BorrarDatos = new borrar_datos (); // Inflate the popup_layout.xml RelativeLayout viewGroup = (RelativeLayout) context.findViewById(R.id.popup); LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_elegir_registros, viewGroup); eleccionIP = (Spinner) layout.findViewById(R.id.popupIP); eleccionRegistro = (Spinner)layout.findViewById(R.id.popupRegistro); /*Cursor cur=BorrarDatos.obtenerIP(); BorrarDatos.rellenarSpinner(cur,eleccionIP);*/ final PopupWindow popup = new PopupWindow(context); popup.setContentView(layout); popup.setWidth(LayoutParams.WRAP_CONTENT); popup.setHeight(LayoutParams.WRAP_CONTENT); popup.setFocusable(true); popup.showAtLocation(layout, Gravity.NO_GRAVITY, 200, 200); ArrayAdapter &lt;CharSequence&gt; adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.add("item 1"); adapter.add("item 2"); eleccionIP.setAdapter(adapter); } </code></pre> <p>Debug:</p> <pre><code>WindowManagerGlobal.addView(View, ViewGroup$LayoutParams, Display, Window) line: 255 WindowManagerImpl.addView(View, ViewGroup$LayoutParams) line: 69 PopupWindow.invokePopup(WindowManager$LayoutParams) line: 993 PopupWindow.showAsDropDown(View, int, int) line: 899 Spinner$DropdownPopup(ListPopupWindow).show() line: 603 Spinner$DropdownPopup.show() line: 981 Spinner.performClick() line: 609 View$PerformClick.run() line: 17355 Handler.handleCallback(Message) line: 725 ViewRootImpl$ViewRootHandler(Handler).dispatchMessage(Message) line: 92 Looper.loop() line: 137 ActivityThread.main(String[]) line: 5041 Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] Method.invoke(Object, Object...) line: 511 ZygoteInit$MethodAndArgsCaller.run() line: 793 ZygoteInit.main(String[]) line: 560 NativeStart.main(String[]) line: not available [native method] </code></pre> <p>The debug of my second mistake:</p> <pre><code>Scada [Android Application] DalvikVM[localhost:8636] Thread [&lt;1&gt; main] (Suspended (exception WindowManager$BadTokenException)) WindowManagerGlobal.addView(View, ViewGroup$LayoutParams, Display, Window) line: 255 WindowManagerImpl.addView(View, ViewGroup$LayoutParams) line: 69 PopupWindow.invokePopup(WindowManager$LayoutParams) line: 993 PopupWindow.showAsDropDown(View, int, int) line: 899 Spinner$DropdownPopup(ListPopupWindow).show() line: 603 Spinner$DropdownPopup.show() line: 981 Spinner.performClick() line: 609 View$PerformClick.run() line: 17355 Handler.handleCallback(Message) line: 725 ViewRootImpl$ViewRootHandler(Handler).dispatchMessage(Message) line: 92 Looper.loop() line: 137 ActivityThread.main(String[]) line: 5041 Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] Method.invoke(Object, Object...) line: 511 ZygoteInit$MethodAndArgsCaller.run() line: 793 ZygoteInit.main(String[]) line: 560 Thread [&lt;10&gt; Binder_2] (Running) Thread [&lt;9&gt; Binder_1] (Running) Thread [&lt;11&gt; AsyncTask #1] (Running) Thread [&lt;12&gt; AsyncTask #2] (Running) Thread [&lt;13&gt; AsyncTask #3] (Running) Thread [&lt;14&gt; AsyncTask #4] (Running) Thread [&lt;15&gt; AsyncTask #5] (Running) </code></pre> <p>I did debug, and error must be here:</p> <pre><code>RelativeLayout viewGroup = (RelativeLayout) ((Activity) context).findViewById(R.id.popup); LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_elegir_registros, viewGroup); eleccionIP = (Spinner)layout.findViewById(R.id.popupIP); eleccionRegistro = (Spinner)layout.findViewById(R.id.popupRegistro); </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