List of usage examples for android.widget GridView setSelectionFromTop
public void setSelectionFromTop(int position, int y)
From source file:Main.java
/** * Scrolls a specific grid view to the item at a specific index. * * @param gridView/* www . j a v a2s .c om*/ * The grid view, which should be scrolled, as an instance of the class {@link * GridView}. The grid view may not be null * @param index * The index of the item, the grid view should be scrolled to, as an {@link Integer} * value * @param offset * The offset of the item, the grid view should be scrolled to, as an {@link Integer} * value */ private static void scrollTo(@NonNull final GridView gridView, final int index, final int offset) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { gridView.setSelectionFromTop(index, offset); } else { gridView.setSelection(index); } }