|
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<ListAdapter>
android.widget.AbsListView
android.widget.ListView
public class ListView
A view that shows items in a vertically scrolling list. The items
come from the ListAdapter associated with this view.
| Nested Class Summary | |
|---|---|
(package private) class |
ListView.FixedViewInfo
|
(package private) static class |
ListView.SavedState
|
| Nested classes/interfaces inherited from class android.widget.AbsListView |
|---|
AbsListView.CheckForTap, AbsListView.LayoutParams, AbsListView.OnScrollListener, AbsListView.RecycleBin, AbsListView.RecyclerListener |
| 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 | |
|---|---|
static int |
CHOICE_MODE_MULTIPLE
The list allows multiple choices |
static int |
CHOICE_MODE_NONE
Normal list that does not indicate choices |
static int |
CHOICE_MODE_SINGLE
The list allows up to one choice |
(package private) Drawable |
mDivider
|
(package private) int |
mDividerHeight
|
(package private) static int |
NO_POSITION
Used to indicate a no preference for a position type. |
| Constructor Summary | |
|---|---|
ListView(Context context)
|
|
ListView(Context context,
AttributeSet attrs)
|
|
ListView(Context context,
AttributeSet attrs,
int defStyle)
|
|
| Method Summary | |
|---|---|
void |
addFooterView(View v)
Add a fixed view to appear at the bottom of the list. |
void |
addFooterView(View v,
Object data,
boolean isSelectable)
Add a fixed view to appear at the bottom of the list. |
void |
addHeaderView(View v)
Add a fixed view to appear at the top of the list. |
void |
addHeaderView(View v,
Object data,
boolean isSelectable)
Add a fixed view to appear at the top of the list. |
(package private) boolean |
arrowScroll(int direction)
Scrolls to the next or previous item if possible. |
protected boolean |
canAnimate()
Indicates whether the view group has the ability to animate its children after the first layout. |
void |
clearChoices()
Clear any choices previously set |
protected void |
dispatchDraw(Canvas canvas)
Called by draw to draw the child views. |
boolean |
dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path. |
(package private) void |
drawDivider(Canvas canvas,
Rect bounds,
int childIndex)
Draws a divider for the given child in the given bounds. |
(package private) void |
fillGap(boolean down)
Fills the gap left open by a touch-scroll. |
(package private) int |
findMotionRow(int y)
Find the row closest to y. |
(package private) View |
findViewInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where,
int id)
|
(package private) View |
findViewTagInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where,
Object tag)
|
protected View |
findViewTraversal(int id)
|
protected View |
findViewWithTagTraversal(Object tag)
|
(package private) boolean |
fullScroll(int direction)
Go to the last or first item if possible (not worrying about panning across or navigating within the internal focus of the currently selected item.) |
ListAdapter |
getAdapter()
Returns the adapter currently in use in this ListView. |
int |
getCheckedItemPosition()
Returns the currently checked item. |
SparseBooleanArray |
getCheckedItemPositions()
Returns the set of checked items in the list. |
int |
getChoiceMode()
|
Drawable |
getDivider()
Returns the drawable that will be drawn between each item in the list. |
int |
getDividerHeight()
|
int |
getFooterViewsCount()
Returns the number of footer views in the list. |
int |
getHeaderViewsCount()
Returns the number of header views in the list. |
boolean |
getItemsCanFocus()
|
int |
getMaxScrollAmount()
|
boolean |
isItemChecked(int position)
Returns the checked state of the specified position. |
protected void |
layoutChildren()
|
(package private) int |
lookForSelectablePosition(int position,
boolean lookDown)
Find a position that can be selected (i.e., is not a separator). |
(package private) int |
measureHeightOfChildren(int widthMeasureSpec,
int startPosition,
int endPosition,
int maxHeight,
int disallowPartialChildPosition)
Measures the height of the given range of children (inclusive) and returns the height with this ListView's padding and divider heights included. |
protected void |
onFinishInflate()
Finalize inflating a view from XML. |
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)
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable. |
boolean |
onKeyMultiple(int keyCode,
int repeatCount,
KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle
the event). |
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 |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
Measure the view and its content to determine the measured width and the measured height. |
void |
onRestoreInstanceState(Parcelable state)
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by View.onSaveInstanceState(). |
Parcelable |
onSaveInstanceState()
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. |
boolean |
onTouchEvent(MotionEvent ev)
Implement this method to handle touch screen motion events. |
(package private) boolean |
pageScroll(int direction)
Scrolls up or down by the number of items currently present on screen. |
boolean |
performItemClick(View view,
int position,
long id)
Call the OnItemClickListener, if it is defined. |
boolean |
removeFooterView(View v)
Removes a previously-added footer view. |
boolean |
removeHeaderView(View v)
Removes a previously-added header view. |
boolean |
requestChildRectangleOnScreen(View child,
Rect rect,
boolean immediate)
Called when a child of this group wants a particular rectangle to be positioned onto the screen. |
(package private) void |
resetList()
The list is empty. |
void |
setAdapter(ListAdapter adapter)
Sets the data behind this ListView. |
void |
setChoiceMode(int choiceMode)
Defines the choice behavior for the List. |
void |
setDivider(Drawable divider)
Sets the drawable that will be drawn between each item in the list. |
void |
setDividerHeight(int height)
Sets the height of the divider that will be drawn between each item in the list. |
void |
setItemChecked(int position,
boolean value)
Sets the checked state of the specified position. |
void |
setItemsCanFocus(boolean itemsCanFocus)
Indicates that the views created by the ListAdapter can contain focusable items. |
void |
setSelection(int position)
Sets the currently selected item |
void |
setSelectionAfterHeaderView()
setSelectionAfterHeaderView set the selection to be the first list item after the header views. |
void |
setSelectionFromTop(int position,
int y)
Sets the selected item and positions the selection y pixels from the top edge of the ListView. |
(package private) void |
setSelectionInt(int position)
Makes the item at the supplied position selected. |
| 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 |
| Field Detail |
|---|
static final int NO_POSITION
public static final int CHOICE_MODE_NONE
public static final int CHOICE_MODE_SINGLE
public static final int CHOICE_MODE_MULTIPLE
Drawable mDivider
int mDividerHeight
| Constructor Detail |
|---|
public ListView(Context context)
public ListView(Context context,
AttributeSet attrs)
public ListView(Context context,
AttributeSet attrs,
int defStyle)
| Method Detail |
|---|
public int getMaxScrollAmount()
public void addHeaderView(View v,
Object data,
boolean isSelectable)
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
v - The view to add.data - Data to associate with this viewisSelectable - whether the item is selectablepublic void addHeaderView(View v)
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
v - The view to add.public int getHeaderViewsCount()
AbsListView
getHeaderViewsCount in class AbsListViewpublic boolean removeHeaderView(View v)
v - The view to remove
public void addFooterView(View v,
Object data,
boolean isSelectable)
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
v - The view to add.data - Data to associate with this viewisSelectable - true if the footer view can be selectedpublic void addFooterView(View v)
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
v - The view to add.public int getFooterViewsCount()
AbsListView
getFooterViewsCount in class AbsListViewpublic boolean removeFooterView(View v)
v - The view to remove
public ListAdapter getAdapter()
setAdapter(ListAdapter) but
might be a WrapperListAdapter.
getAdapter in class AdapterView<ListAdapter>setAdapter(ListAdapter)public void setAdapter(ListAdapter adapter)
WrapperListAdapter,
depending on the ListView features currently in use. For instance, adding
headers and/or footers will cause the adapter to be wrapped.
setAdapter in class AdapterView<ListAdapter>adapter - The ListAdapter which is responsible for maintaining the
data backing this list and for producing a view to represent an
item in that data set.getAdapter()void resetList()
resetList in class AbsListView
public boolean requestChildRectangleOnScreen(View child,
Rect rect,
boolean immediate)
ViewGroupViewGroups overriding this can trust
that:
ViewGroups overriding this should uphold the contract:
requestChildRectangleOnScreen in class ViewGroupchild - The direct child making the request.rect - The rectangle in the child's coordinates the child
wishes to be on the screen.immediate - True to forbid animated or delayed scrolling,
false otherwise
void fillGap(boolean down)
fillGap in class AbsListViewdown - true if the scroll is going down, false if it is going up
protected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
View
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by View.measure(int, int) and
should be overriden 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 an
IllegalStateException, thrown by
View.measure(int, int). Calling the superclass'
View.onMeasure(int, int) 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 View.onMeasure(int, int) to provide better measurements of
their content.
If this method is overridden, it is the subclass's responsibility to make
sure the measured height and width are at least the view's minimum height
and width (View.getSuggestedMinimumHeight() and
View.getSuggestedMinimumWidth()).
onMeasure in class AbsListViewwidthMeasureSpec - horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec.heightMeasureSpec - vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec.View.getMeasuredWidth(),
View.getMeasuredHeight(),
View.setMeasuredDimension(int, int),
View.getSuggestedMinimumHeight(),
View.getSuggestedMinimumWidth(),
View.MeasureSpec.getMode(int),
View.MeasureSpec.getSize(int)
final int measureHeightOfChildren(int widthMeasureSpec,
int startPosition,
int endPosition,
int maxHeight,
int disallowPartialChildPosition)
widthMeasureSpec - The width measure spec to be given to a child's
View.measure(int, int).startPosition - The position of the first child to be shown.endPosition - The (inclusive) position of the last child to be
shown. Specify NO_POSITION if the last child should be
the last available child from the adapter.maxHeight - The maximum height that will be returned (if all the
children don't fit in this value, this value will be
returned).disallowPartialChildPosition - In general, whether the returned
height should only contain entire children. This is more
powerful--it is the first inclusive position at which partial
children will not be allowed. Example: it looks nice to have
at least 3 completely visible children, and in portrait this
will most likely fit; but in landscape there could be times
when even 2 children can not be completely shown, so a value
of 2 (remember, inclusive) would be good (assuming
startPosition is 0).
int findMotionRow(int y)
AbsListView
findMotionRow in class AbsListViewy - Where the user touched
protected void layoutChildren()
layoutChildren in class AbsListViewprotected boolean canAnimate()
ViewGroup
canAnimate in class AdapterView<ListAdapter>public void setSelection(int position)
setSelection in class AdapterView<ListAdapter>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.
public void setSelectionFromTop(int position,
int y)
position - Index (starting at 0) of the data item to be selected.y - The distance from the top edge of the ListView (plus padding) that the
item will be positioned.void setSelectionInt(int position)
setSelectionInt in class AbsListViewposition - the position of the item to select
int lookForSelectablePosition(int position,
boolean lookDown)
lookForSelectablePosition in class AdapterView<ListAdapter>position - The starting position to look at.lookDown - Whether to look down for other positions.
AdapterView.INVALID_POSITION if nothing can be found.public void setSelectionAfterHeaderView()
public boolean dispatchKeyEvent(KeyEvent event)
ViewGroup
dispatchKeyEvent in class ViewGroupevent - The key event to be dispatched.
public boolean onKeyDown(int keyCode,
KeyEvent event)
ViewKeyEvent.Callback.onKeyMultiple(): perform press of the view
when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER
is released, if the view is enabled and clickable.
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.
public boolean onKeyMultiple(int keyCode,
int repeatCount,
KeyEvent event)
ViewKeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle
the event).
onKeyMultiple in interface KeyEvent.CallbackonKeyMultiple in class ViewkeyCode - A key code that represents the button pressed, from
KeyEvent.repeatCount - The number of times the action was made.event - The KeyEvent object that defines the button action.
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 AbsListViewkeyCode - A key code that represents the button pressed, from
KeyEvent.event - The KeyEvent object that defines the button action.
boolean pageScroll(int direction)
direction - either View.FOCUS_UP or View.FOCUS_DOWN
boolean fullScroll(int direction)
direction - either View.FOCUS_UP or View.FOCUS_DOWN
boolean arrowScroll(int direction)
direction - either View.FOCUS_UP or View.FOCUS_DOWN
public void setItemsCanFocus(boolean itemsCanFocus)
itemsCanFocus - true if items can get focus, false otherwisepublic boolean getItemsCanFocus()
protected void dispatchDraw(Canvas canvas)
ViewGroup
dispatchDraw in class AbsListViewcanvas - the canvas on which to draw the view
void drawDivider(Canvas canvas,
Rect bounds,
int childIndex)
canvas - The canvas to draw to.bounds - The bounds of the divider.childIndex - The index of child (of the View) above the divider.
This will be -1 if there is no child above the divider to be
drawn.public Drawable getDivider()
public void setDivider(Drawable divider)
setDividerHeight(int)
divider - The drawable to use.public int getDividerHeight()
public void setDividerHeight(int height)
setDivider(Drawable)
height - The new height of the divider in pixels.
protected void onFocusChanged(boolean gainFocus,
int direction,
Rect previouslyFocusedRect)
View
onFocusChanged in class AbsListViewgainFocus - 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.protected void onFinishInflate()
ViewEven if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called.
onFinishInflate in class Viewprotected View findViewTraversal(int id)
ViewGroup
findViewTraversal in class ViewGroupid - the id of the view to be found
View findViewInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where,
int id)
protected View findViewWithTagTraversal(Object tag)
ViewGroup
findViewWithTagTraversal in class ViewGrouptag - the tag of the view to be found
View findViewTagInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where,
Object tag)
public boolean onTouchEvent(MotionEvent ev)
View
onTouchEvent in class AbsListViewev - The motion event.
public int getChoiceMode()
setChoiceMode(int)public void setChoiceMode(int choiceMode)
CHOICE_MODE_NONE). By setting the choiceMode to CHOICE_MODE_SINGLE, the
List allows up to one item to be in a chosen state. By setting the choiceMode to
CHOICE_MODE_MULTIPLE, the list allows any number of items to be chosen.
choiceMode - One of CHOICE_MODE_NONE, CHOICE_MODE_SINGLE, or
CHOICE_MODE_MULTIPLE
public boolean performItemClick(View view,
int position,
long id)
AdapterView
performItemClick in class AdapterView<ListAdapter>view - The view within the AdapterView that was clicked.position - The position of the view in the adapter.id - The row id of the item that was clicked.
public void setItemChecked(int position,
boolean value)
CHOICE_MODE_SINGLE or
CHOICE_MODE_MULTIPLE.
position - The item whose checked state is to be checkedvalue - The new checked sate for the itempublic boolean isItemChecked(int position)
CHOICE_MODE_SINGLE
or CHOICE_MODE_MULTIPLE.
position - The item whose checked state to return
setChoiceMode(int)public int getCheckedItemPosition()
CHOICE_MODE_SINGLE.
AdapterView.INVALID_POSITION if nothing is selectedsetChoiceMode(int)public SparseBooleanArray getCheckedItemPositions()
CHOICE_MODE_SINGLE.
public void clearChoices()
public Parcelable onSaveInstanceState()
ViewSome examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
onSaveInstanceState in class AbsListViewView.onRestoreInstanceState(android.os.Parcelable),
View.saveHierarchyState(android.util.SparseArray) ,
View.dispatchSaveInstanceState(android.util.SparseArray) ,
View.setSaveEnabled(boolean)public void onRestoreInstanceState(Parcelable state)
ViewView.onSaveInstanceState(). This function will never be called with a
null state.
onRestoreInstanceState in class AbsListViewstate - The frozen state that had previously been returned by
View.onSaveInstanceState().View.onSaveInstanceState(),
View.restoreHierarchyState(android.util.SparseArray) ,
View.dispatchRestoreInstanceState(android.util.SparseArray)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||