android姜饼Gridview提供NullPointerException android.widget.Gridview.fillUp

android姜饼Gridview提供NullPointerException android.widget.Gridview.fillUp,android,gridview,Android,Gridview,我有下面的GridView,它有时会崩溃,给我一个空指针 Adroid GridView.java源代码中出现异常 这似乎只发生在Android 2.3.7-GingerbreadAPI 10上 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertic

我有下面的GridView,它有时会崩溃,给我一个空指针 Adroid GridView.java源代码中出现异常

这似乎只发生在Android 2.3.7-GingerbreadAPI 10上

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/main_gridFragment"

        >

    <include
        layout="@layout/toolbar_new"/>


    <include
        layout="@layout/heading_bar"
        />


    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <GridView
            android:id="@+id/main_grid"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:columnWidth="100dp"
            android:numColumns="auto_fit"
            android:verticalSpacing="0dp"
            android:horizontalSpacing="10dp"
            android:stretchMode="columnWidth"
            android:gravity="center"
            >
        </GridView>

        <!-- the Z index is determined by ordering, this is displayed over the Gridview -->
        <!-- android:id="@+id/menu" -->
        <include
            layout="@layout/menu"/>

    </FrameLayout>


</LinearLayout>


第311行的mrReferenceView似乎为空//mReferenceView将随着对makeRow()的每次调用而更改。

我已成功找到导致问题的问题。 调用时,姜饼按照上面的堆栈跟踪失败并崩溃:

gridView.smoothScrollToPosition(0);
通过简单地取消呼叫,我成功地解决了问题。测试这个 在实际设备上:

Motorola MB525, Android version 2.3.7
More details on the device:
Kernel 2.6.32.9-gb08c3c8 Build number MUI-3.1.27, Fri Jun 3 11:40:33 CST 2011
这不会修复错误:

            gridView.post(new Runnable() {
                @Override
                public void run() {
                    gridView.smoothScrollToPosition(0);
                }
            });
可能重复的
            gridView.post(new Runnable() {
                @Override
                public void run() {
                    gridView.smoothScrollToPosition(0);
                }
            });