android: Unable to set fast scroll on gridview

1k Views Asked by At

for some reasons I m not able to setup fast scroll on gridview.

mWebsitesGrid = (GridView) websitesView.findViewById(R.id.websitesGrid);
boolean fastScrollSet = mWebsitesGrid.isFastScrollEnabled();

if(!fastScrollSet)
{
    mWebsitesGrid.setFastScrollEnabled(true);
}

boolean fastScrollSetTemp = mWebsitesGrid.isFastScrollEnabled();

At the end of this code fastScrollSetTemp is still false. I have even specified the fast scroll option in xml

<?xml version="1.0" encoding="utf-8"?>
<GridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/websitesGrid"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:columnWidth="150dp"
    android:gravity="center"
    android:horizontalSpacing="10dp"
    android:numColumns="auto_fit"
    android:stretchMode="columnWidth"
    android:verticalSpacing="10dp" 
    android:fastScrollEnabled="true"
    />

still i dont see the fast scroll . What is wrong ?

1

There are 1 best solutions below

0
On

I know this is a late answer but fast scroll is only activated when the total height of the ListView is 4 times or more bigger than its visible height.

//Minimum number of pages to justify showing a fast scroll thumb.
private static final int MIN_PAGES = 4;

From: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/widget/FastScroller.java#FastScroller