|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.view.View
android.view.ViewGroup
android.widget.AdapterView<SpinnerAdapter>
android.widget.AbsSpinner
android.widget.Gallery
public class Gallery
A view that shows items in a center-locked, horizontally scrolling list.
The default values for the Gallery assume you will be using
R.styleable.Theme_galleryItemBackground as the background for
each View given to the Gallery from the Adapter. If you are not doing this,
you may need to adjust some Gallery properties, such as the spacing.
| Nested Class Summary | |
|---|---|
static class |
Gallery.LayoutParams
Gallery extends LayoutParams to provide a place to hold current Transformation information along with previous position/transformation info. |
| Nested classes/interfaces inherited from class android.widget.AbsSpinner |
|---|
AbsSpinner.RecycleBin, AbsSpinner.SavedState |
| Nested classes/interfaces inherited from class android.widget.AdapterView |
|---|
AdapterView.AdapterContextMenuInfo, AdapterView.AdapterDataSetObserver, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener, AdapterView.OnItemSelectedListener |
| Nested classes/interfaces inherited from class android.view.ViewGroup |
|---|
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener |
| Nested classes/interfaces inherited from class android.view.View |
|---|
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener |
| Field Summary |
|---|
| Fields inherited from class android.widget.AbsSpinner |
|---|
mAdapter, mBlockLayoutRequests, mHeightMeasureSpec, mInterpolator, mRecycler, mSelectedView, mSelectionBottomPadding, mSelectionLeftPadding, mSelectionRightPadding, mSelectionTopPadding, mSpinnerPadding, mWidthMeasureSpec |
| Constructor Summary | |
|---|---|
Gallery(Context context)
|
|
Gallery(Context context,
AttributeSet attrs)
|
|
Gallery(Context context,
AttributeSet attrs,
int defStyle)
|
|
| Method Summary | |
|---|---|
protected boolean |
checkLayoutParams(ViewGroup.LayoutParams p)
|
protected int |
computeHorizontalScrollExtent()
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. |
protected int |
computeHorizontalScrollOffset()
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. |
protected int |
computeHorizontalScrollRange()
Compute the horizontal range that the horizontal scrollbar represents. |
boolean |
dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path. |
protected void |
dispatchSetPressed(boolean pressed)
Dispatch setPressed to all of this View's children. |
void |
dispatchSetSelected(boolean selected)
Dispatch setSelected to all of this View's children. |
protected ViewGroup.LayoutParams |
generateDefaultLayoutParams()
Returns a set of default layout parameters. |
ViewGroup.LayoutParams |
generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set. |
protected ViewGroup.LayoutParams |
generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params. |
protected int |
getChildDrawingOrder(int childCount,
int i)
Returns the index of the child to draw for this iteration. |
(package private) int |
getChildHeight(View child)
|
protected boolean |
getChildStaticTransformation(View child,
Transformation t)
|
protected ContextMenu.ContextMenuInfo |
getContextMenuInfo()
Views should implement this if they have extra information to associate with the context menu. |
(package private) int |
getLimitedMotionScrollAmount(boolean motionToLeft,
int deltaX)
|
(package private) void |
layout(int delta,
boolean animate)
Creates and positions all views for this Gallery. |
(package private) boolean |
moveNext()
|
(package private) boolean |
movePrevious()
|
(package private) void |
onCancel()
Called when a touch event's action is MotionEvent.ACTION_CANCEL. |
boolean |
onDown(MotionEvent e)
Notified when a tap occurs with the down MotionEvent
that triggered it. |
boolean |
onFling(MotionEvent e1,
MotionEvent e2,
float velocityX,
float velocityY)
Notified of a fling event when it occurs with the initial on down MotionEvent
and the matching up MotionEvent. |
protected void |
onFocusChanged(boolean gainFocus,
int direction,
Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes. |
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 KeyEvent.KEYCODE_DPAD_CENTER or
KeyEvent.KEYCODE_ENTER is released. |
protected 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 |
onLongPress(MotionEvent e)
Notified when a long press occurs with the initial on down MotionEvent
that trigged it. |
boolean |
onScroll(MotionEvent e1,
MotionEvent e2,
float distanceX,
float distanceY)
Notified when a scroll occurs with the initial on down MotionEvent and the
current move MotionEvent. |
void |
onShowPress(MotionEvent e)
The user has performed a down MotionEvent and not performed
a move or up yet. |
boolean |
onSingleTapUp(MotionEvent e)
Notified when a tap occurs with the up MotionEvent
that triggered it. |
boolean |
onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events. |
(package private) void |
onUp()
Called when a touch event's action is MotionEvent.ACTION_UP. |
(package private) void |
selectionChanged()
|
void |
setAnimationDuration(int animationDurationMillis)
Sets how long the transition animation should run when a child view changes position. |
void |
setCallbackDuringFling(boolean shouldCallback)
Whether or not to callback on any AdapterView.getOnItemSelectedListener()
while the items are being flinged. |
void |
setCallbackOnUnselectedItemClick(boolean shouldCallback)
Whether or not to callback when an item that is not selected is clicked. |
void |
setGravity(int gravity)
Describes how the child views are aligned. |
(package private) void |
setSelectedPositionInt(int position)
Utility to keep mSelectedPosition and mSelectedRowId in sync |
void |
setSpacing(int spacing)
Sets the spacing between items in a Gallery |
void |
setUnselectedAlpha(float unselectedAlpha)
Sets the alpha of items that are not selected in the Gallery. |
boolean |
showContextMenu()
Bring up the context menu for this view. |
boolean |
showContextMenuForChild(View originalView)
Bring up a context menu for the specified view or its ancestors. |
(package private) void |
trackMotionScroll(int deltaX)
Tracks a motion scroll. |
| Methods inherited from class android.widget.AbsSpinner |
|---|
getAdapter, getChildWidth, getCount, getSelectedView, handleDataChanged, onMeasure, onRestoreInstanceState, onSaveInstanceState, pointToPosition, recycleAllViews, requestLayout, resetList, setAdapter, setSelection, setSelection, setSelectionInt |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface android.view.ViewParent |
|---|
createContextMenu, getParent, isLayoutRequested |
| Constructor Detail |
|---|
public Gallery(Context context)
public Gallery(Context context,
AttributeSet attrs)
public Gallery(Context context,
AttributeSet attrs,
int defStyle)
| Method Detail |
|---|
public void setCallbackDuringFling(boolean shouldCallback)
AdapterView.getOnItemSelectedListener()
while the items are being flinged. If false, only the final selected item
will cause the callback. If true, all items between the first and the
final will cause callbacks.
shouldCallback - Whether or not to callback on the listener while
the items are being flinged.public void setCallbackOnUnselectedItemClick(boolean shouldCallback)
AdapterView.getOnItemClickListener() will get the callback.
shouldCallback - Whether or not to callback on the listener when a
item that is not selected is clicked.public void setAnimationDuration(int animationDurationMillis)
animationDurationMillis - The duration of the transition, in
milliseconds.public void setSpacing(int spacing)
spacing - The spacing in pixels between items in the Gallerypublic void setUnselectedAlpha(float unselectedAlpha)
unselectedAlpha - the alpha for the items that are not selected.
protected boolean getChildStaticTransformation(View child,
Transformation t)
ViewGroup
getChildStaticTransformation in class ViewGroupprotected int computeHorizontalScrollExtent()
ViewCompute the horizontal extent of the horizontal scrollbar's thumb within the horizontal 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.computeHorizontalScrollRange() and
View.computeHorizontalScrollOffset().
The default extent is the drawing width of this view.
computeHorizontalScrollExtent in class ViewView.computeHorizontalScrollRange(),
View.computeHorizontalScrollOffset(),
ScrollBarDrawableprotected int computeHorizontalScrollOffset()
ViewCompute the horizontal offset of the horizontal 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.computeHorizontalScrollRange() and
View.computeHorizontalScrollExtent().
The default offset is the scroll offset of this view.
computeHorizontalScrollOffset in class ViewView.computeHorizontalScrollRange(),
View.computeHorizontalScrollExtent(),
ScrollBarDrawableprotected int computeHorizontalScrollRange()
ViewCompute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the
units used by View.computeHorizontalScrollExtent() and
View.computeHorizontalScrollOffset().
The default range is the drawing width of this view.
computeHorizontalScrollRange in class ViewView.computeHorizontalScrollExtent(),
View.computeHorizontalScrollOffset(),
ScrollBarDrawableprotected boolean checkLayoutParams(ViewGroup.LayoutParams p)
ViewGroup
checkLayoutParams in class ViewGroupprotected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
ViewGroupViewGroup.checkLayoutParams(android.view.ViewGroup.LayoutParams), this method
is invoked. This method should return a new set of layout params suitable for
this ViewGroup, possibly by copying the appropriate attributes from the
specified set of layout params.
generateLayoutParams in class ViewGroupp - The layout parameters to convert into a suitable set of layout parameters
for this ViewGroup.
ViewGroup.LayoutParams or one
of its descendantspublic ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
ViewGroup
generateLayoutParams in class ViewGroupattrs - the attributes to build the layout parameters from
ViewGroup.LayoutParams or one
of its descendantsprotected ViewGroup.LayoutParams generateDefaultLayoutParams()
ViewGroupViewGroup.addView(View) has no layout parameters
already set. If null is returned, an exception is thrown from addView.
generateDefaultLayoutParams in class AbsSpinner
protected void onLayout(boolean changed,
int l,
int t,
int r,
int b)
ViewGroup
onLayout in class AdapterView<SpinnerAdapter>changed - This is a new size or position for this viewl - Left position, relative to parentt - Top position, relative to parentr - Right position, relative to parentb - Bottom position, relative to parentint getChildHeight(View child)
getChildHeight in class AbsSpinnervoid trackMotionScroll(int deltaX)
deltaX - Change in X from the previous event.
int getLimitedMotionScrollAmount(boolean motionToLeft,
int deltaX)
void selectionChanged()
selectionChanged in class AdapterView<SpinnerAdapter>
void layout(int delta,
boolean animate)
We layout rarely, most of the time trackMotionScroll(int) takes
care of repositioning, adding, and removing children.
layout in class AbsSpinnerdelta - Change in the selected position. +1 means the selection is
moving to the right, so views are scrolling to the left. -1
means the selection is moving to the left.public boolean onTouchEvent(MotionEvent event)
View
onTouchEvent in class Viewevent - The motion event.
public boolean onSingleTapUp(MotionEvent e)
MotionEvent
that triggered it.
onSingleTapUp in interface GestureDetector.OnGestureListenere - The up motion event that completed the first tap
public boolean onFling(MotionEvent e1,
MotionEvent e2,
float velocityX,
float velocityY)
MotionEvent
and the matching up MotionEvent. The calculated velocity is supplied along
the x and y axis in pixels per second.
onFling in interface GestureDetector.OnGestureListenere1 - The first down motion event that started the fling.e2 - The move motion event that triggered the current onFling.velocityX - The velocity of this fling measured in pixels per second
along the x axis.velocityY - The velocity of this fling measured in pixels per second
along the y axis.
public boolean onScroll(MotionEvent e1,
MotionEvent e2,
float distanceX,
float distanceY)
MotionEvent and the
current move MotionEvent. The distance in x and y is also supplied for
convenience.
onScroll in interface GestureDetector.OnGestureListenere1 - The first down motion event that started the scrolling.e2 - The move motion event that triggered the current onScroll.distanceX - The distance along the X axis that has been scrolled since the last
call to onScroll. This is NOT the distance between e1
and e2.distanceY - The distance along the Y axis that has been scrolled since the last
call to onScroll. This is NOT the distance between e1
and e2.
public boolean onDown(MotionEvent e)
MotionEvent
that triggered it. This will be triggered immediately for
every down event. All other events should be preceded by this.
onDown in interface GestureDetector.OnGestureListenere - The down motion event.void onUp()
void onCancel()
public void onLongPress(MotionEvent e)
MotionEvent
that trigged it.
onLongPress in interface GestureDetector.OnGestureListenere - The initial on down motion event that started the longpress.public void onShowPress(MotionEvent e)
MotionEvent and not performed
a move or up yet. This event is commonly used to provide visual
feedback to the user to let them know that their action has been
recognized i.e. highlight an element.
onShowPress in interface GestureDetector.OnGestureListenere - The down motion eventpublic void dispatchSetSelected(boolean selected)
ViewGroup
dispatchSetSelected in class ViewGroupselected - The new selected stateView.setSelected(boolean)protected void dispatchSetPressed(boolean pressed)
View
dispatchSetPressed in class ViewGrouppressed - The new pressed stateView.setPressed(boolean)protected ContextMenu.ContextMenuInfo getContextMenuInfo()
ViewOnCreateContextMenuListener#onCreateContextMenu(ContextMenu, View, ContextMenuInfo)
callback.
getContextMenuInfo in class Viewpublic boolean showContextMenuForChild(View originalView)
ViewGroup
In most cases, a subclass does not need to override this. However, if
the subclass is added directly to the window manager (for example,
ViewManager.addView(View, android.view.ViewGroup.LayoutParams))
then it should override this and show the context menu.
showContextMenuForChild in interface ViewParentshowContextMenuForChild in class ViewGrouporiginalView - The source view where the context menu was first invoked
public boolean showContextMenu()
View
showContextMenu in class Viewpublic boolean dispatchKeyEvent(KeyEvent event)
ViewGroup
dispatchKeyEvent in class ViewGroupevent - The key event to be dispatched.
public boolean onKeyDown(int keyCode,
KeyEvent event)
onKeyDown in interface KeyEvent.CallbackonKeyDown in class ViewkeyCode - A key code that represents the button pressed, from
KeyEvent.event - The KeyEvent object that defines the button action.
View.onKeyDown(int, android.view.KeyEvent)
public boolean onKeyUp(int keyCode,
KeyEvent event)
ViewKeyEvent.Callback.onKeyMultiple(): perform clicking of the view
when KeyEvent.KEYCODE_DPAD_CENTER or
KeyEvent.KEYCODE_ENTER is released.
onKeyUp in interface KeyEvent.CallbackonKeyUp in class ViewkeyCode - A key code that represents the button pressed, from
KeyEvent.event - The KeyEvent object that defines the button action.
boolean movePrevious()
boolean moveNext()
void setSelectedPositionInt(int position)
AdapterView
setSelectedPositionInt in class AdapterView<SpinnerAdapter>position - Our current positionpublic void setGravity(int gravity)
gravity -
protected int getChildDrawingOrder(int childCount,
int i)
ViewGroup
NOTE: In order for this method to be called, the
ViewGroup.FLAG_USE_CHILD_DRAWING_ORDER must be set.
getChildDrawingOrder in class ViewGroupi - The current iteration.
protected void onFocusChanged(boolean gainFocus,
int direction,
Rect previouslyFocusedRect)
View
onFocusChanged in class ViewgainFocus - True if the View has focus; false otherwise.direction - The direction focus has moved when requestFocus()
is called to give this view focus. Values are
View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or
View.FOCUS_RIGHT. 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 be null otherwise.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||