Class GridView
- All Implemented Interfaces:
Drawable.Callback
,ViewManager
,ViewParent
,Filter.FilterListener
ListAdapter
associated with this view.-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.widget.AbsListView
AbsListView.LayoutParams, AbsListView.MultiChoiceModeListener, AbsListView.OnScrollListener, AbsListView.RecyclerListener, AbsListView.SelectionBoundsAdjuster
Nested classes/interfaces inherited from class icyllis.modernui.widget.AdapterView
AdapterView.AdapterContextMenuInfo, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener, AdapterView.OnItemSelectedListener
Nested classes/interfaces inherited from class icyllis.modernui.view.ViewGroup
ViewGroup.MarginLayoutParams
Nested classes/interfaces inherited from class icyllis.modernui.view.View
View.DragShadow, View.Focusable, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.NestedScrollType, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollAxis, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Creates as many columns as can fit on screen.static final int
Disables stretching.static final int
Stretches columns.static final int
Stretches the spacing between columns.static final int
Stretches the spacing between columns.Fields inherited from class icyllis.modernui.widget.AbsListView
CHOICE_MODE_MULTIPLE, CHOICE_MODE_MULTIPLE_MODAL, CHOICE_MODE_NONE, CHOICE_MODE_SINGLE, TRANSCRIPT_MODE_ALWAYS_SCROLL, TRANSCRIPT_MODE_DISABLED, TRANSCRIPT_MODE_NORMAL
Fields inherited from class icyllis.modernui.widget.AdapterView
INVALID_POSITION, INVALID_ROW_ID, ITEM_VIEW_TYPE_HEADER_OR_FOOTER, ITEM_VIEW_TYPE_IGNORE
Fields inherited from class icyllis.modernui.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_DISALLOW_INTERCEPT, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS
Fields inherited from class icyllis.modernui.view.View
ALPHA, BOTTOM, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, LAYOUT_DIRECTION_UNDEFINED, LEFT, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mScrollX, mScrollY, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, RIGHT, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLL_X, SCROLL_Y, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TOP, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, TYPE_NON_TOUCH, TYPE_TOUCH, VIEW_MARKER, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
Compute the vertical extent of the vertical scrollbar's thumb within the vertical range.protected int
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range.protected int
Compute the vertical range that the vertical scrollbar represents.Returns the adapter currently associated with this widget.int
Return the width of a column in the grid.int
Describes how the child views are horizontally aligned.int
Returns the amount of horizontal spacing currently used between each item in the grid.int
Get the number of columns in the grid.int
Return the requested width of a column in the grid.int
Returns the requested amount of horizontal spacing between each item in the grid.int
int
Returns the amount of vertical spacing between each item in the grid.protected void
Subclasses must override this method to layout their children.protected void
onFocusChanged
(boolean gainFocus, int direction, Rect previouslyFocusedRect) Called by the view system when the focus state of this view changes.boolean
Default implementation: perform press of the view whenKeyEvent.KEY_ENTER
,KeyEvent.KEY_KP_ENTER
orKeyEvent.KEY_SPACE
is released, if the view is enabled and clickable.boolean
onKeyMultiple
(int keyCode, int repeatCount, KeyEvent event) boolean
Default implementation: perform clicking of the view whenKeyEvent.KEY_ENTER
,KeyEvent.KEY_KP_ENTER
orKeyEvent.KEY_SPACE
is released.protected void
onMeasure
(int widthMeasureSpec, int heightMeasureSpec) Measure the view and its content to determine the measured width and the measured height.void
setAdapter
(ListAdapter adapter) Sets the data behind this GridView.void
setColumnWidth
(int columnWidth) Set the width of columns in the grid.void
setGravity
(int gravity) Set the gravity for this grid.void
setHorizontalSpacing
(int horizontalSpacing) Set the amount of horizontal (x) spacing to place between each item in the grid.void
setNumColumns
(int numColumns) Set the number of columns in the gridvoid
setSelection
(int position) Sets the currently selected itemvoid
setStretchMode
(int stretchMode) Control how items are stretched to fill their space.void
setVerticalSpacing
(int verticalSpacing) Set the amount of vertical (y) spacing to place between each item in the grid.void
smoothScrollByOffset
(int offset) Smoothly scroll to the specified adapter position offset.void
smoothScrollToPosition
(int position) Smoothly scroll to the specified adapter position.Methods inherited from class icyllis.modernui.widget.AbsListView
addTouchables, canScrollList, checkLayoutParams, clearChoices, dispatchDraw, dispatchDrawableHotspotChanged, dispatchSetPressed, drawableStateChanged, fling, generateDefaultLayoutParams, generateLayoutParams, getBottomEdgeEffectColor, getCheckedItemCount, getCheckedItemIds, getCheckedItemPosition, getCheckedItemPositions, getChoiceMode, getContextMenuInfo, getFocusedRect, getListPaddingBottom, getListPaddingLeft, getListPaddingRight, getListPaddingTop, getSelectedView, getSelector, getTopEdgeEffectColor, getTranscriptMode, handleDataChanged, internalSetPadding, invalidateViews, isDrawSelectorOnTop, isItemChecked, isSmoothScrollbarEnabled, isStackFromBottom, onAttachedToWindow, onCancelPendingInputEvents, onDetachedFromWindow, onDrawForeground, onFilterComplete, onGenericMotionEvent, onInterceptTouchEvent, onLayout, onNestedFling, onNestedScroll, onNestedScrollAccepted, onOverScrolled, onSizeChanged, onStartNestedScroll, onTouchEvent, onTouchModeChanged, onWindowFocusChanged, performItemClick, pointToPosition, pointToRowId, reclaimViews, requestDisallowInterceptTouchEvent, requestLayout, scrollListBy, setBottomEdgeEffectColor, setChoiceMode, setDrawSelectorOnTop, setEdgeEffectColor, setFriction, setItemChecked, setMultiChoiceModeListener, setOnScrollListener, setRecyclerListener, setScrollIndicators, setSelectionFromTop, setSelector, setSmoothScrollbarEnabled, setStackFromBottom, setTopEdgeEffectColor, setTranscriptMode, setVelocityScale, shouldDrawSelector, showContextMenu, showContextMenuForChild, smoothScrollBy, smoothScrollToPosition, smoothScrollToPositionFromTop, smoothScrollToPositionFromTop, verifyDrawable
Methods inherited from class icyllis.modernui.widget.AdapterView
addView, addView, addView, addView, getCount, getEmptyView, getFirstVisiblePosition, getItemAtPosition, getItemIdAtPosition, getLastVisiblePosition, getOnItemClickListener, getOnItemLongClickListener, getOnItemSelectedListener, getPositionForView, getSelectedItem, getSelectedItemId, getSelectedItemPosition, removeAllViews, removeView, removeViewAt, setEmptyView, setFocusable, setFocusableInTouchMode, setOnClickListener, setOnItemClickListener, setOnItemLongClickListener, setOnItemSelectedListener
Methods inherited from class icyllis.modernui.view.ViewGroup
addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTransientView, addView, addViewInLayout, addViewInLayout, attachViewToParent, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchFinishTemporaryDetach, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchSetActivated, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchTouchEvent, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawChild, endViewTransition, findFocus, findViewByPredicateTraversal, findViewTraversal, focusableViewAvailable, focusSearch, getChildAt, getChildCount, getChildDrawingOrder, getChildDrawingOrder, getChildMeasureSpec, getChildVisibleRect, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutTransition, getNestedScrollAxes, getTouchscreenBlocksFocus, getTransientView, getTransientViewCount, getTransientViewIndex, hasBooleanFlag, hasFocus, hasTransientState, indexOfChild, isChildrenDrawingOrderEnabled, isLayoutSuppressed, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onChildVisibilityChanged, onCreateDrawableState, onInterceptHoverEvent, onNestedPreFling, onNestedPreScroll, onRequestFocusInDescendants, onResolvePointerIcon, onSetLayoutParams, onStopNestedScroll, onViewAdded, onViewRemoved, removeAllViewsInLayout, removeDetachedView, removeTransientView, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestFocus, requestTransitionStart, resetResolvedDrawables, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveTextAlignment, resolveTextDirection, restoreDefaultFocus, setAddStatesFromChildren, setBooleanFlag, setChildrenDrawingOrderEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutTransition, setTouchscreenBlocksFocus, setTransitionGroup, shouldDelayChildPressedState, startActionModeForChild, startViewTransition, suppressLayout, transformPointToViewLocal, updateViewLayout
Methods inherited from class icyllis.modernui.view.View
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, awakenScrollBars, awakenScrollBars, callOnClick, cancelLongPress, cancelPendingInputEvents, canReceivePointerEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, createContextMenu, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dp, draw, drawableHotspotChanged, findViewById, findViewByPredicate, findViewByPredicateInsideOut, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAlpha, getAnimationMatrix, getBackground, getBaseline, getBottom, getBoundsOnScreen, getBoundsOnScreen, getContext, getDefaultSize, getDrawableState, getDrawingRect, getElevation, getFadingEdge, getFadingEdgeLength, getFocusable, getFocusables, getForeground, getForegroundGravity, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getInverseMatrix, getKeyDispatcherState, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOnLongClickListener, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getPivotX, getPivotY, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getRevealOnFocusHint, getRight, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTextAlignment, getTextDirection, getTooltipText, getTooltipView, getTop, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewRoot, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowVisibility, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasIdentityMatrix, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasTranslationTransientState, hasWindowFocus, invalidate, invalidateDrawable, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForegroundInsidePadding, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isInLayout, isInScrollingContainer, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isPaddingRelative, isPivotSet, isPressed, isRootNamespace, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, keyboardNavigationClusterSearch, mapRectFromViewToScreenCoords, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onCreateContextMenu, onDragEvent, onDraw, onDrawScrollBars, onFinishTemporaryDetach, onHoverChanged, onHoverEvent, onKeyShortcut, onResolveDrawables, onRtlPropertiesChanged, onScrollChanged, onStartTemporaryDetach, onVisibilityAggregated, onVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestFocus, requestFocus, requestRectangleOnScreen, requestRectangleOnScreen, requireViewById, resetPivot, resolveSize, resolveSizeAndState, scheduleDrawable, scrollBy, scrollTo, setActivated, setAlpha, setAnimationMatrix, setBackground, setBottom, setClickable, setContextClickable, setDuplicateParentStateEnabled, setElevation, setEnabled, setFocusable, setFocusedByDefault, setFocusedInCluster, setForeground, setForegroundGravity, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHasTranslationTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setIsRootNamespace, setKeyboardNavigationCluster, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnTouchListener, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotDraw, setX, setY, setZ, showContextMenu, sp, startActionMode, startActionMode, startDragAndDrop, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, willNotDraw
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface icyllis.modernui.view.ViewParent
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch
-
Field Details
-
NO_STRETCH
public static final int NO_STRETCHDisables stretching.- See Also:
-
STRETCH_SPACING
public static final int STRETCH_SPACINGStretches the spacing between columns.- See Also:
-
STRETCH_COLUMN_WIDTH
public static final int STRETCH_COLUMN_WIDTHStretches columns.- See Also:
-
STRETCH_SPACING_UNIFORM
public static final int STRETCH_SPACING_UNIFORMStretches the spacing between columns. The spacing is uniform.- See Also:
-
AUTO_FIT
public static final int AUTO_FITCreates as many columns as can fit on screen.- See Also:
-
-
Constructor Details
-
GridView
-
-
Method Details
-
getAdapter
Description copied from class:AdapterView
Returns the adapter currently associated with this widget.- Specified by:
getAdapter
in classAdapterView<ListAdapter>
- Returns:
- The adapter used to provide this view's content.
-
setAdapter
Sets the data behind this GridView.- Overrides:
setAdapter
in classAbsListView
- Parameters:
adapter
- the adapter providing the grid's data
-
smoothScrollToPosition
public void smoothScrollToPosition(int position) Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed.- Overrides:
smoothScrollToPosition
in classAbsListView
- Parameters:
position
- Scroll to this adapter position.
-
smoothScrollByOffset
public void smoothScrollByOffset(int offset) Smoothly scroll to the specified adapter position offset. The view will scroll such that the indicated position is displayed.- Parameters:
offset
- The amount to offset from the adapter position to scroll to.
-
onMeasure
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) Description copied from class:View
Measure the view and its content to determine the measured width and the measured height. This method is invoked byView.measure(int, int)
and should be overridden by subclasses to provide accurate and efficient measurement of their contents.CONTRACT: When overriding this method, you must call
View.setMeasuredDimension(int, int)
to store the measured width and height of this view. Failure to do so will trigger anIllegalStateException
, thrown byView.measure(int, int)
. Calling super.onMeasure() is a valid use.The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override the base one to provide better measurements of their content.
- Overrides:
onMeasure
in classAbsListView
- Parameters:
widthMeasureSpec
- width measure specification imposed by the parentMeasureSpec
heightMeasureSpec
- height measure specification imposed by the parentMeasureSpec
-
layoutChildren
protected void layoutChildren()Description copied from class:AbsListView
Subclasses must override this method to layout their children.- Overrides:
layoutChildren
in classAbsListView
-
setSelection
public void setSelection(int position) Sets the currently selected item- Specified by:
setSelection
in classAdapterView<ListAdapter>
- Parameters:
position
- Index (starting at 0) of the data item to be selected.If in touch mode, the item will not be selected but it will still be positioned appropriately.
-
onKeyDown
Description copied from class:View
Default implementation: perform press of the view whenKeyEvent.KEY_ENTER
,KeyEvent.KEY_KP_ENTER
orKeyEvent.KEY_SPACE
is released, if the view is enabled and clickable.- Overrides:
onKeyDown
in classAbsListView
- Parameters:
keyCode
- a key code that represents the button pressed, fromKeyEvent
event
- the KeyEvent object that defines the button action
-
onKeyMultiple
-
onKeyUp
Description copied from class:View
Default implementation: perform clicking of the view whenKeyEvent.KEY_ENTER
,KeyEvent.KEY_KP_ENTER
orKeyEvent.KEY_SPACE
is released.- Overrides:
onKeyUp
in classAbsListView
- Parameters:
keyCode
- A key code that represents the button pressed, fromKeyEvent
.event
- The KeyEvent object that defines the button action.
-
onFocusChanged
Description copied from class:View
Called by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from. When overriding, be sure to call up through to the super class so that the standard focus handling will occur.- Overrides:
onFocusChanged
in classAbsListView
- Parameters:
gainFocus
- True if the View has focus; false otherwise.direction
- The direction focus has moved when requestFocus() is called to give this view focus. Values areView.FOCUS_UP
,View.FOCUS_DOWN
,View.FOCUS_LEFT
,View.FOCUS_RIGHT
,View.FOCUS_FORWARD
, orView.FOCUS_BACKWARD
. It may not always apply, in which case use the default.previouslyFocusedRect
- The rectangle, in this view's coordinate system, of the previously focused view. If applicable, this will be passed in as finer grained information about where the focus is coming from (in addition to direction). Will benull
otherwise.
-
setGravity
public void setGravity(int gravity) Set the gravity for this grid. Gravity describes how the child views are horizontally aligned. Defaults to Gravity.LEFT- Parameters:
gravity
- the gravity to apply to this grid's children
-
getGravity
public int getGravity()Describes how the child views are horizontally aligned. Defaults to Gravity.LEFT- Returns:
- the gravity that will be applied to this grid's children
-
setHorizontalSpacing
public void setHorizontalSpacing(int horizontalSpacing) Set the amount of horizontal (x) spacing to place between each item in the grid.- Parameters:
horizontalSpacing
- The amount of horizontal space between items, in pixels.
-
getHorizontalSpacing
public int getHorizontalSpacing()Returns the amount of horizontal spacing currently used between each item in the grid.This is only accurate for the current layout. If
setHorizontalSpacing(int)
has been called but layout is not yet complete, this method may return a stale value. To get the horizontal spacing that was explicitly requested usegetRequestedHorizontalSpacing()
.- Returns:
- Current horizontal spacing between each item in pixels
- See Also:
-
getRequestedHorizontalSpacing
public int getRequestedHorizontalSpacing()Returns the requested amount of horizontal spacing between each item in the grid.The value returned may have been supplied during inflation as part of a style, the default GridView style, or by a call to
setHorizontalSpacing(int)
. If layout is not yet complete or if GridView calculated a different horizontal spacing from what was requested, this may return a different value fromgetHorizontalSpacing()
.- Returns:
- The currently requested horizontal spacing between items, in pixels
- See Also:
-
setVerticalSpacing
public void setVerticalSpacing(int verticalSpacing) Set the amount of vertical (y) spacing to place between each item in the grid.- Parameters:
verticalSpacing
- The amount of vertical space between items, in pixels.- See Also:
-
getVerticalSpacing
public int getVerticalSpacing()Returns the amount of vertical spacing between each item in the grid.- Returns:
- The vertical spacing between items in pixels
- See Also:
-
setStretchMode
public void setStretchMode(int stretchMode) Control how items are stretched to fill their space.- Parameters:
stretchMode
- EitherNO_STRETCH
,STRETCH_SPACING
,STRETCH_SPACING_UNIFORM
, orSTRETCH_COLUMN_WIDTH
.
-
getStretchMode
public int getStretchMode() -
setColumnWidth
public void setColumnWidth(int columnWidth) Set the width of columns in the grid.- Parameters:
columnWidth
- The column width, in pixels.
-
getColumnWidth
public int getColumnWidth()Return the width of a column in the grid.This may not be valid yet if a layout is pending.
- Returns:
- The column width in pixels
- See Also:
-
getRequestedColumnWidth
public int getRequestedColumnWidth()Return the requested width of a column in the grid.This may not be the actual column width used. Use
getColumnWidth()
to retrieve the current real width of a column.- Returns:
- The requested column width in pixels
- See Also:
-
setNumColumns
public void setNumColumns(int numColumns) Set the number of columns in the grid- Parameters:
numColumns
- The desired number of columns.
-
getNumColumns
public int getNumColumns()Get the number of columns in the grid. ReturnsAUTO_FIT
if the Grid has never been laid out.- See Also:
-
computeVerticalScrollExtent
protected int computeVerticalScrollExtent()Description copied from class:View
Compute the vertical extent of the vertical scrollbar's thumb within the vertical range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by
View.computeVerticalScrollRange()
andView.computeVerticalScrollOffset()
.The default extent is the drawing height of this view.
- Overrides:
computeVerticalScrollExtent
in classAbsListView
- Returns:
- the vertical extent of the scrollbar's thumb
- See Also:
-
computeVerticalScrollOffset
protected int computeVerticalScrollOffset()Description copied from class:View
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by
View.computeVerticalScrollRange()
andView.computeVerticalScrollExtent()
.The default offset is the scroll offset of this view.
- Overrides:
computeVerticalScrollOffset
in classAbsListView
- Returns:
- the vertical offset of the scrollbar's thumb
- See Also:
-
computeVerticalScrollRange
protected int computeVerticalScrollRange()Description copied from class:View
Compute the vertical range that the vertical scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by
View.computeVerticalScrollExtent()
andView.computeVerticalScrollOffset()
.- Overrides:
computeVerticalScrollRange
in classAbsListView
- Returns:
- the total vertical range represented by the vertical scrollbar
The default range is the drawing height of this view.
- See Also:
-