Error spinner in popup window when I click

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.

Here you have my below code and debug, because logcat I get everything right.

 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 <CharSequence> 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);




    }

Debug:

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]  

The debug of my second mistake:

Scada [Android Application] 
    DalvikVM[localhost:8636]    
        Thread [<1> 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 [<10> Binder_2] (Running)    
        Thread [<9> Binder_1] (Running) 
        Thread [<11> AsyncTask #1] (Running)    
        Thread [<12> AsyncTask #2] (Running)    
        Thread [<13> AsyncTask #3] (Running)    
        Thread [<14> AsyncTask #4] (Running)    
        Thread [<15> AsyncTask #5] (Running)

I did debug, and error must be here:

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);

Adding android:spinnerMode="dialog" in spinner solved my problem.

How to create a Spinner widget inside of a PopupWindow in Android? Get BadTokenException when clicking on Spinner

android - Error spinner in popup window when I click, Adding android:spinnerMode="dialog" in spinner solved my problem. How to create a Spinner widget inside of a PopupWindow in Android? In the below example i have created display spinner in popup window. here i have created a popup.xml layout. in popup layot i have added textview, imageview, spinner and button. and in activity_main.xml layout i have added a button to open spinner popup window. see the below code it will clearly described you to make spinner in popup window.step(1)-main.xml layout-&lt;linearlayout xmlns


I solved this same problem.Add your spinner in xml class.

android:spinnerMode="dialog"

android Error spinner in popup window when I click?, android Error spinner in popup window when I click? ArrayAdapter < CharSequence> adapter = new ArrayAdapter(this,android.R.layout. simple_spinner_item� It's a example to display Spinner in PopupWindow. For simple example of using Android PopupWindow, refer to the post . Create /res/layout/popup.xml to define the view of the PopupWindow.


try this,

//Declaer your array list fist and add some itms

  private ArrayList<String> item = new ArrayList<String>();
  item.add("1");
  item.add("2");

// Change your array adapter like this

  ArrayAdapter <CharSequence> adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item,list);
       adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  eleccionIP.setAdapter(adapter);

Spinner, getPrompt; onClick; onResolvePointerIcon; onRestoreInstanceState; onSaveInstanceState Use a dialog window for selecting spinner options. Set a horizontal offset in pixels for the spinner's popup window of choices. Failure to do so will trigger an IllegalStateException , thrown by measure(int, int) . PopupWindow is a pop-up control that can be used to display any View and float at the top of the activity. Through PopupWindow we can achieve a variety of pop-up window effect such as information display or UI interaction. The PopupWindow custom layout is more convenient, and the display position is freedom there is not any restricted.


replace the appropriate lines with this and see what happens:

final View layout = layoutInflater.inflate(R.layout.popup_elegir_registros, new ViewGroup(this) {

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        // TODO Auto-generated method stub

    }
});

    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);

    new Handler().postDelayed(new Runnable(){

        public void run() {
            popup.showAtLocation(layout, Gravity.NO_GRAVITY, 200, 200);
        }

    }, 100L);

    ArrayAdapter <CharSequence> 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);

and this will help in creating a popupwindow and this also

How to make Spinner in Popup Window in android., In the below example i have created display spinner in popup window. here i have click here" /></linearlayout>step(2)-create a new layout-popup.xml-<?xml � Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.


If you want to set spinner inside popup window then do the following:

//this your inside layout
final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//and that is your spinner
ArrayAdapter<String> adapterState =
                new ArrayAdapter<String>(
                        layoutInflater.getContext(),
                        android.R.layout.simple_spinner_item,
                        keysState);

        adapterState.setDropDownViewResource(
                android.R.layout.simple_spinner_dropdown_item);
        spinnerState.setAdapter(adapterState);

Use layout.getContext() instead of getApplicationContext() or Activty.this etc because your are inside the another layout view.

Display Spinner inside PopupWindow, It's a example to display Spinner in PopupWindow. For simple OnClickListener () { @Override public void onClick(View arg0) { LayoutInflater� If I click on a file to open it, for example, whereas before it would just open, now I get the window with all the options from that file or shortcut. I then either have to click open again in the window. or press ESC to get rid of the window and try to click again. Sometimes this unwanted window will just keep opening, and it is very frustrating.


Android Spinner - drop down list, Android Spinner Example, Android Drop Down List, android studio spinner, using android bundle and showing popup notification using android toast. On button click we pass the selected spinner item as a string value to the next but if i click on this button then application is closed and main thread error is occurred. Now Select the identified Window and double click on that, this will display a Yes in the Auto Close column of the Window list. Note : You can double click the Window Name again to remove the Automatic Closing of the Window. Note : You can even click on name Auto Close to remove all the automatic close tasks.


Clicking spinner within popup window causes WindowManager , Clicking spinner within popup window causes WindowManager$ BadTokenException. Question. I've looked up a couple of posts for the same problem but can't� When I click the link that uses a pop-up window. The window opens ok and the data in the pop-up is the right size but the size of the window is too small. You can't see all the text in the window its


Android Custom Spinner Dialog Example, Unlike spinner in the submit button then click the android spinner dialog as shown in That error made in android spinner example see this is the dialog helps you Via custom android dialog message is available on a small popup window,� Windows 10 start menu wont pop up, even after clicking the windows button or the icon I do not have this problem until this morning, i tried restarting my PC several times but it wouldn't work. It was ok yesterday right after i upgraded from windows 8.1 pro.