I'm using the StickyGridHeader library for a gridview. I want to scroll the gridview to a specific location based on the item that it should be displaying in a view.

I've tried using setSelection to the index of that item in the gridview that I expect to use, but it has a tendency to overshoot or undershoot the location that I expect in grids with different numbers of columns.

I am able to set the correct location in a grid with one column (essentially a list) using setSelection and finding the item this way:

```
    event = getEventThatWeWantByDate();
    //Find and store event's position in the gridview
    for( int i = 0; i < getGridView().getAdapter().getCount(); i++ ) {
        gridEvent = (Event) getGridView().getItemAtPosition( i );
        if( !( gridEvent instanceof Event ) )
            continue;
        if( gridEvent.getEventDate() == event.getEventDate() ) {
            index = i;
            break;
        }
    }

```

Then I use index to bring it up. I also have another function for counting the amount of blanks in my grid: 

```
    int blanks = 0;
    int sumOfAllLastRowItems = 0;
    //Get the number of blanks in the grid up until the desired item
    for( int i = 0; i < headers; i++ ) {
        int numOfItemsInLastRow = wrapper.getCountForHeader( i ) % getResources().getInteger( R.integer.event_grid_num_columns );
        //Log.e( TAG, "Num in area: " + numOfItemsInLastRow );
        if( numOfItemsInLastRow != 0 ) {
            sumOfAllLastRowItems += numOfItemsInLastRow;
            int numOfBlankSpaces = ( getResources().getInteger( R.integer.event_grid_num_columns ) ) - numOfItemsInLastRow;
        //  Log.e( TAG, "Adding num of blanks: " + numOfBlankSpaces );
            blanks += numOfBlankSpaces;
        }
        else sumOfAllLastRowItems += getResources().getInteger( R.integer.event_grid_num_columns );
    }

```

As well as the number of headers before the item that I want:

```
    StickyGridHeadersSimpleAdapterWrapper wrapper = new StickyGridHeadersSimpleAdapterWrapper( (StickyEventViewGridAdapter) getAdapter() );
    int headers = 0;
    //Count number of headers before the requested event
    for( int i = 0, j = 0; i < wrapper.getNumHeaders() ; i++ ) {
        j += wrapper.getCountForHeader( i );
        headers++;
        if( j >= arrayIndex ) {
            break;
        }
    }

```

I've tried adding the amount of blanks and headers to the index, and that works great if there's two columns, but then if I make the grid use 3 columns it will go an unrelated location again.

Any suggestions?

02-06 16:31:03.147 8711-8711/? E/EventGridFragment﹕ Number of Headers Before Item: 24

02-06 16:31:03.147 8711-8711/? E/EventGridFragment﹕ Sticky Grid Adapter Index: 71

02-06 16:31:03.147 8711-8711/? E/EventGridFragment﹕ Array Adapter Index: 45

02-06 16:31:03.147 8711-8711/? E/EventGridFragment﹕ Blanks: 28

02-06 16:31:03.147 8711-8711/? E/EventGridFragment﹕ Value to return: 123

I'm actually looking for an item ~150 in the gridview when my number of columns is 3.