Code example for GridView

Methods: scrollToBottomgetHeightgetChildAtgetChildCountgetListPaddingBottomgetAdapter, getSelectedItemPosition

        assertEquals(mGridView.getAdapter().getCount() - 1, mGridView.getSelectedItemPosition());
    public void testPushUp() { 
        TouchUtils.scrollToBottom(this, mGridView);
        // Nothing should be selected 
        assertEquals("Selection still available after touch", -1,
        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);
        assertEquals("Last item not the last child in the grid",
                mGridView.getAdapter().getCount() - 1, lastChild.getId());
        assertEquals("Last item not at the bottom of the grid",
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());
    public void testPullDown() { 
        TouchUtils.scrollToTop(this, mGridView);
Stop searching for code, let great code find you!  Add Codota to your java IDE