为什么GridView只显示有限的项目?

时间:2016-07-12 17:52:46

标签: android gridview

我像文档here一样实现了GridView。根据示例22应该出现项目/图像,具有垂直滚动,但对于我来说仅出现9个图像。为什么呢?

GridView的设置中猜错了什么?

<GridView
        android:id="@+id/gridView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="4dp"
        android:columnWidth="100dp"
        android:gravity="center"
        android:numColumns="9"
        android:horizontalSpacing="1dp"
        android:scrollbarAlwaysDrawHorizontalTrack="true"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbars="horizontal"
        android:stretchMode="none"
        android:verticalSpacing="1dp">

getCount方法返回22,我的列表中有22个图像。

public int getCount() {

    int jj = mThumbIds.length;
    return mThumbIds.length;
}

private Integer[] mThumbIds = {
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5,
        R.drawable.printable_number_5, R.drawable.printable_number_5
};

0 个答案:

没有答案