我有一个自定义列表视图,其中微调器作为行的一个组件。我正在使用片段,所以我按照以下方式扩充布局:
this._inflater = LayoutInflater.from(context);
,其中
context = getActivity().getApplicationContext().
我对微调器的布局是:
<Spinner
android:id="@+id/spTipoDispProteccion"
android:layout_width="0dp"
android:textColor="@color/NEGRO"
android:layout_weight="3.1"
style="@style/DropDownAltaFacil"
android:spinnerMode="dialog"
android:entries="@array/OPCIONES_TIPO_DISP_SEGURIDAD"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
/>
当我选择微调器时,为了选择一个值,它会崩溃并向我显示错误添加窗口标记null。 我尝试传递getActivity()但不起作用。
有什么想法吗?
这是我的日志:
11-25 16:47:53.351: E/AndroidRuntime(21116): FATAL EXCEPTION: main
11-25 16:47:53.351: E/AndroidRuntime(21116): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.view.ViewRootImpl.setView(ViewRootImpl.java:801)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:265)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:73)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.app.Dialog.show(Dialog.java:282)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.app.AlertDialog$Builder.show(AlertDialog.java:951)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.widget.Spinner$DialogPopup.show(Spinner.java:878)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.widget.Spinner.performClick(Spinner.java:614)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.view.View$PerformClick.run(View.java:18190)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.os.Handler.handleCallback(Handler.java:725)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.os.Handler.dispatchMessage(Handler.java:92)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.os.Looper.loop(Looper.java:175)
11-25 16:47:53.351: E/AndroidRuntime(21116): at android.app.ActivityThread.main(ActivityThread.java:5279)
11-25 16:47:53.351: E/AndroidRuntime(21116): at java.lang.reflect.Method.invokeNative(Native Method)
11-25 16:47:53.351: E/AndroidRuntime(21116): at java.lang.reflect.Method.invoke(Method.java:511)
11-25 16:47:53.351: E/AndroidRuntime(21116): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
11-25 16:47:53.351: E/AndroidRuntime(21116): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
11-25 16:47:53.351: E/AndroidRuntime(21116): at dalvik.system.NativeStart.main(Native Method)