1

我正在使用 ActionBar Sherlock 和SlidingMenu。该应用程序有一个像 facebook android 应用程序这样的抽屉:

在此处输入图像描述

单击列表中的任何项目后,它会检查您是否已注册,如果没有,它将显示一个膨胀的布局(就像一个对话框),然后您需要填写它。

我在那个膨胀的布局中填充微调器。

它在 Android Gingerbread 中正确显示并且运行流畅,但在 Android jellybean 中它显示正确,但是当我单击它时它崩溃并强制关闭。

logcat 中显示的错误是这样的:

11-15 10:28:36.665: D/VelocityTracker(6271): VelocityTracker: int datax = 12
11-15 10:28:36.665: D/VelocityTracker(6271): VelocityTracker: int m_velocity_magnify_x = 1.200000
11-15 10:28:36.665: D/VelocityTracker(6271): VelocityTracker: int datay = 16
11-15 10:28:36.665: D/VelocityTracker(6271): VelocityTracker: int m_velocity_magnify_y = 1.600000
11-15 10:28:36.758: I/SurfaceTextureClient(6271): [STC::queueBuffer] this:0x53828d30, api:1, last queue time elapsed :21436 ms
11-15 10:28:36.759: I/SurfaceTextureClient(6271): [0x53828d30] frames:16, duration:21.702999, fps:0.737206
11-15 10:28:36.795: D/AbsListView(6271): checkAbsListViewlLogProperty get invalid command
11-15 10:28:36.809: D/AndroidRuntime(6271): Shutting down VM
11-15 10:28:36.809: W/dalvikvm(6271): threadid=1: thread exiting with uncaught exception (group=0x40e84908)
11-15 10:28:36.836: E/AndroidRuntime(6271): FATAL EXCEPTION: main
11-15 10:28:36.836: E/AndroidRuntime(6271): android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@417634b8 is not valid; is your activity running?
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.view.ViewRootImpl.setView(ViewRootImpl.java:652)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:328)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:226)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:151)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.view.Window$LocalWindowManager.addView(Window.java:547)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.widget.PopupWindow.invokePopup(PopupWindow.java:988)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:897)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.widget.ListPopupWindow.show(ListPopupWindow.java:603)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.widget.Spinner$DropdownPopup.show(Spinner.java:974)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.widget.Spinner.performClick(Spinner.java:604)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.view.View$PerformClick.run(View.java:17072)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.os.Handler.handleCallback(Handler.java:615)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.os.Looper.loop(Looper.java:153)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at android.app.ActivityThread.main(ActivityThread.java:5042)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at java.lang.reflect.Method.invokeNative(Native Method)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at java.lang.reflect.Method.invoke(Method.java:511)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
11-15 10:28:36.836: E/AndroidRuntime(6271):     at dalvik.system.NativeStart.main(Native Method)

这是我的代码:

popup_form

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="#FFFFFF">

    <ScrollView 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:gravity="center"
                android:layout_centerInParent="true">

                <LinearLayout 
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="left"
                        android:src="@drawable/ic_logo"/>

                    <View 
                        android:layout_width="fill_parent"
                        android:layout_height="3dip"
                        android:background="@color/light_gray" />

                    <LinearLayout 
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <TextView 
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:text="Sample form"/>

                        <EditText
                            android:id="@+id/etSPDOB"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="5dp"
                            android:textSize="14sp"
                            android:editable="false"
                            android:hint="@string/dob" />

                        <Spinner
                            android:id="@+id/spCountry"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:entries="@array/country_array"
                            android:entryValues="@array/country_code"
                            android:prompt="@string/select_country"/>

                        <LinearLayout
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:weightSum="2">

                            <Button
                                android:id="@+id/btnSPCancel"
                                android:layout_weight="1"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:text="Cancel"
                                android:textSize="12sp" />

                            <Button
                                android:id="@+id/btnSPSet"
                                android:layout_weight="1"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:text="Set"
                                android:textSize="12sp" />

                        </LinearLayout>

                    </LinearLayout>

                </LinearLayout>

            </RelativeLayout>

    </ScrollView>   

</LinearLayout>

数组.xml

<string-array name="country_array">
    <item>Australia</item>
    <item>New Zealand</item>
    <item>United Kingdom</item>
</string-array>
4

0 回答 0