弹出窗口中的错误微调框

弹出窗口中的错误微调框

本文介绍了当我单击时,弹出窗口中的错误微调框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序如果将一个按钮弹出一个弹出窗口,该弹出窗口具有两个微调器,那么我就可以在那里弹出该窗口,但是当我收到错误消息时,是单击微调器.

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.

这里您有下面的代码并进行调试,因为logcat使我一切正常.

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




    }

调试:

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]

第二个错误的调试:

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

推荐答案

在Spinner中添加 android:spinnerMode ="dialog" 解决了我的问题.

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

这篇关于当我单击时,弹出窗口中的错误微调框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:52