English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.Gallery

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.view.ViewGroup ViewManager ViewParent
android.widget.AdapterView
android.widget.Gallery

A view that shows items in a center-locked, horizontally scrolling list. The items in the gallery come from the GalleryAdapter associated with this view.

Nested Classes
Gallery.LayoutParams Gallery extends LayoutParams to provide a place to hold current Transformation information along with previous position/transformation info. 

Summary

XML Attributes

Attribute name Related methods  
android:animationDuration setAnimationDuration(int)
 
Sets how long a transition animation should run (in milliseconds) when layout has changed. 
android:drawSelectorOnTop setDrawSelectorOnTop(boolean)
 
 
android:gravity setGravity(int)
 
Specifies how to place an object, both its x and y axis, within a larger containing object. 
android:spacing setSpacing(int)
 
 
android:spinnerSelector setSelectorSkin(Drawable)
 
 
XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View
Constants inherited from class android.widget.AdapterView
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View

Fields

protected      SpinnerAdapter  mAdapter   
protected      Boolean  mAllowWrap   
protected      boolean  mBlockLayoutRequests   
protected      boolean  mDrawSelectorOnTop   
protected      int  mGravity   
protected      int  mHeightMeasureSpec   
protected      Interpolator  mInterpolator   
protected      int  mOldSelectedPosition   
protected      boolean  mPerformItemClickOnCenterKey  Whether to performItemClick when the center/enter key is pushed. 
protected      RecycleBin  mRecycler   
protected      View  mSelectedView   
protected      int  mSelectionBottomPadding   
protected      int  mSelectionLeftPadding   
protected      int  mSelectionRightPadding   
protected      int  mSelectionTopPadding   
protected      Drawable  mSelector   
protected      Rect  mSelectorRect   
protected      Rect  mSpinnerPadding   
protected      int  mWidthMeasureSpec   
Fields inherited from class android.widget.AdapterView
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

          Gallery(Context context)
          Gallery(Context context, AttributeSet attrs, Map inflateParams)
          Gallery(Context context, AttributeSet attrs, Map inflateParams, int defStyle)

Public Methods

        void  dispatchWindowFocusChanged(boolean hasFocus)
Called when the window containing this view gains or loses window focus.
        void  draw(Canvas canvas)
Override to handle drawing the selector
        LayoutParams  generateLayoutParams(AttributeSet attrs)
        SpinnerAdapter  getAdapter()
        Boolean  getAllowWrap()
        int  getCount()
        View  getSelectedView()
        boolean  onKeyDown(int keyCode, KeyEvent event)
Handles left, right, and clicking
        boolean  onKeyUp(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_NEWLINE is released.
        boolean  onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
        void  onWindowFocusChanged(boolean hasWindowFocus)
Called when the window containing this view gains or loses focus.
        int  pointToPosition(int x, int y)
Maps a point to a position in the list.
        void  requestLayout()
Override to prevent spamming ourselves with layout requests as we place views
        void  setAdapter(SpinnerAdapter adapter)
The Adapter is used to provide the data which backs this Spinner.
        void  setAllowWrap(Boolean allowWrap)
        void  setAnimateNextLayout(boolean animate)
Controls whether the children of this view will animate the next time they go through layout.
        void  setAnimationDuration(int animationDurationMillis)
Sets how long the transition animation should run when a chid view changes position.
        void  setDrawSelectorOnTop(boolean onTop)
Indicates whether to draw the selector before or after drawing our children
        void  setGravity(int gravity)
Describes how the child views are aligned.
        void  setScrollIndicators(View left, View right)
Set the views that will be used to indicate that the gallery can be scrolled left or right
        void  setSelection(int position, boolean animate)
Jump directly to a specific item in the adapter data.
        void  setSelection(int position)
Sets the currently selected item
        void  setSelectorSkin(Drawable sel)
Sets a drawable to put around the selected item
        void  setSpacing(int spacing)
Sets the spacing between items in a Gallery
        boolean  verifyDrawable(Drawable dr)
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

Protected Methods

        void  checkSelectionChanged()
        int  computeHorizontalScrollExtent()

Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range.

        int  computeHorizontalScrollOffset()

Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range.

        int  computeHorizontalScrollRange()

Compute the horizontal range that the horizontal scrollbar represents.

        int[]  createSelectorState(int extraSpace)
        void  drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
        int  getChildHeight(View child)
        boolean  getChildStaticTransformation(View child, Transformation t)
When a gallery draws, some of its children may be permanently transformed.
        int  getChildWidth(View child)
        LayoutParams  getDefaultLayoutParams()
        int[]  getSelectorState(int extraSpace)
        void  handleDataChanged()
        void  layout(int delta, boolean animate)
Creates and positions all views for this Gallery.
        boolean  moveNext()
        boolean  movePrevious()
        int[]  onCreateDrawableState(int extraSpace)
Generate the new Drawable state for this view.
        void  onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes.
        void  onLayout(boolean changed, int l, int t, int r, int b)
Called from layout when this view should assign a size and position to each of its children.
        void  onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

        void  positionSelector(int l, int t, int r, int b)
Utility to setup mSelectorRect
        void  recycleAllViews()
        void  resetList()
Clear out all children from the list
        void  setSelectionInt(int position, boolean animate)
Makes the item at the supplied position selected.
        void  updateScrollIndicators()
Make the state of the scroll indicators match the state of the selection
        void  updateSelectorState()
Methods inherited from class android.widget.AdapterView