public abstract class

HtcAdapterView

extends ViewGroup
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.htc.widget.HtcAdapterView<T extends android.widget.Adapter>
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

An AdapterView is a view whose children are determined by an Adapter.

See HtcListView, HtcGridView, Spinner and Gallery for commonly used subclasses of AdapterView.

Developer Guides

For more information about using AdapterView, read the Binding to Data with AdapterView developer guide.

Summary

Nested Classes
class HtcAdapterView.AdapterContextMenuInfo Extra menu information provided to the onCreateContextMenu(ContextMenu, View, ContextMenuInfo) callback when a context menu is brought up for this AdapterView. 
enum HtcAdapterView.ListStyle  
interface HtcAdapterView.OnItemClickListener Interface definition for a callback to be invoked when an item in this AdapterView has been clicked. 
interface HtcAdapterView.OnItemLongClickListener Interface definition for a callback to be invoked when an item in this view has been clicked and held. 
interface HtcAdapterView.OnItemSelectedListener Interface definition for a callback to be invoked when an item in this view has been selected. 
Constants
int INVALID_POSITION Represents an invalid position.
long INVALID_ROW_ID Represents an empty or invalid row id
int ITEM_VIEW_TYPE_HEADER_OR_FOOTER The item view type returned by getItemViewType(int) when the item is a header or footer.
int ITEM_VIEW_TYPE_IGNORE The item view type returned by getItemViewType(int) when the adapter does not want the item's view recycled.
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.ViewGroup
From class android.view.View
Public Constructors
HtcAdapterView(Context context)
HtcAdapterView(Context context, AttributeSet attrs)
HtcAdapterView(Context context, AttributeSet attrs, int defStyle)
Public Methods
void addView(View child)
This method is not supported and throws an UnsupportedOperationException when called.
void addView(View child, int index)
This method is not supported and throws an UnsupportedOperationException when called.
void addView(View child, int index, ViewGroup.LayoutParams params)
This method is not supported and throws an UnsupportedOperationException when called.
void addView(View child, ViewGroup.LayoutParams params)
This method is not supported and throws an UnsupportedOperationException when called.
boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)
abstract T getAdapter()
Returns the adapter currently associated with this widget.
int getCount()
View getEmptyView()
When the current adapter is empty, the AdapterView can display a special view call the empty view.
int getFirstVisiblePosition()
Returns the position within the adapter's data set for the first item displayed on screen.
Object getItemAtPosition(int position)
Gets the data associated with the specified position in the list.
long getItemIdAtPosition(int position)
int getLastVisiblePosition()
Returns the position within the adapter's data set for the last item displayed on screen.
final HtcAdapterView.OnItemClickListener getOnItemClickListener()
final HtcAdapterView.OnItemLongClickListener getOnItemLongClickListener()
final HtcAdapterView.OnItemSelectedListener getOnItemSelectedListener()
int getPositionForView(View view)
Gets the position within the adapter's data set for the view, where view is a an adapter item or a descendant of an adapter item.
Object getSelectedItem()
long getSelectedItemId()
int getSelectedItemPosition()
Returns the position of the currently selected item within the adapter's data set
abstract View getSelectedView()
void onInitializeAccessibilityEvent(AccessibilityEvent event)
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event)
boolean performItemClick(View view, int position, long id)
Calls the OnItemClickListener, if it is defined.
void removeAllViews()
This method is not supported and throws an UnsupportedOperationException when called.
void removeView(View child)
This method is not supported and throws an UnsupportedOperationException when called.
void removeViewAt(int index)
This method is not supported and throws an UnsupportedOperationException when called.
abstract void setAdapter(T adapter)
Sets the adapter that provides the data and the views to represent the data in this widget.
void setEmptyView(View emptyView)
Sets the view to show if the adapter is empty
void setFocusable(boolean focusable)
void setFocusableInTouchMode(boolean focusable)
void setListStyle(HtcAdapterView.ListStyle style)
void setOnClickListener(View.OnClickListener l)
void setOnItemClickListener(HtcAdapterView.OnItemClickListener listener)
Registers a callback to be invoked when an item in this AdapterView has been clicked.
void setOnItemLongClickListener(HtcAdapterView.OnItemLongClickListener listener)
Registers a callback to be invoked when an item in this AdapterView has been clicked and held
void setOnItemSelectedListener(HtcAdapterView.OnItemSelectedListener listener)
Registers a callback to be invoked when an item in this AdapterView has been selected.
abstract void setSelection(int position)
Sets the currently selected item.
Protected Methods
boolean canAnimate()
void dispatchRestoreInstanceState(SparseArray<Parcelable> container)
Overrides to prevent thawing of any views created by the adapter.
void dispatchSaveInstanceState(SparseArray<Parcelable> container)
Overrides to prevent freezing of any views created by the adapter.
void onDetachedFromWindow()
void onLayout(boolean changed, int left, int top, int right, int bottom)
[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.graphics.drawable.Drawable.Callback2
From interface android.view.HtcIfViewGroup
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Constants

public static final int INVALID_POSITION

Since: API Level 2.0

Represents an invalid position. All valid positions are in the range 0 to 1 less than the number of items in the current adapter.

Constant Value: -1 (0xffffffff)

public static final long INVALID_ROW_ID

Since: API Level 2.0

Represents an empty or invalid row id

Constant Value: -9223372036854775808 (0x8000000000000000)

public static final int ITEM_VIEW_TYPE_HEADER_OR_FOOTER

Since: API Level 2.0

The item view type returned by getItemViewType(int) when the item is a header or footer.

Constant Value: -2 (0xfffffffe)

public static final int ITEM_VIEW_TYPE_IGNORE

Since: API Level 2.0

The item view type returned by getItemViewType(int) when the adapter does not want the item's view recycled.

Constant Value: -1 (0xffffffff)

Public Constructors

public HtcAdapterView (Context context)

Since: API Level 2.0

public HtcAdapterView (Context context, AttributeSet attrs)

Since: API Level 2.0

public HtcAdapterView (Context context, AttributeSet attrs, int defStyle)

Since: API Level 2.0

Public Methods

public void addView (View child)

Since: API Level

This method is not supported and throws an UnsupportedOperationException when called.

Parameters
child Child view
Throws
UnsupportedOperationException Every time this method is invoked.

public void addView (View child, int index)

Since: API Level

This method is not supported and throws an UnsupportedOperationException when called.

Parameters
child Child view.
index Child index.
Throws
UnsupportedOperationException Every time this method is invoked.

public void addView (View child, int index, ViewGroup.LayoutParams params)

Since: API Level

This method is not supported and throws an UnsupportedOperationException when called.

Parameters
child Child view.
index Child index.
params Child view params.
Throws
UnsupportedOperationException Every time this method is invoked.

public void addView (View child, ViewGroup.LayoutParams params)

Since: API Level

This method is not supported and throws an UnsupportedOperationException when called.

Parameters
child Child view.
params Child view params.
Throws
UnsupportedOperationException Every time this method is invoked.

public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)

Since: API Level

public abstract T getAdapter ()

Since: API Level 2.0

Returns the adapter currently associated with this widget.

Returns
  • The adapter used to provide this view's content.

public int getCount ()

Since: API Level 2.0

Returns
  • The number of items owned by the Adapter associated with this AdapterView. (This is the number of data items, which may be larger than the number of visible views.)

public View getEmptyView ()

Since: API Level 2.0

When the current adapter is empty, the AdapterView can display a special view call the empty view. The empty view is used to provide feedback to the user that no data is available in this AdapterView.

Returns
  • The view to show if the adapter is empty.

public int getFirstVisiblePosition ()

Since: API Level 2.0

Returns the position within the adapter's data set for the first item displayed on screen.

Returns
  • The position within the adapter's data set

public Object getItemAtPosition (int position)

Since: API Level 2.0

Gets the data associated with the specified position in the list.

Parameters
position Which data to get
Returns
  • The data associated with the specified position in the list

public long getItemIdAtPosition (int position)

Since: API Level 2.0

public int getLastVisiblePosition ()

Since: API Level 2.0

Returns the position within the adapter's data set for the last item displayed on screen.

Returns
  • The position within the adapter's data set

public final HtcAdapterView.OnItemClickListener getOnItemClickListener ()

Since: API Level 2.0

Returns
  • The callback to be invoked with an item in this AdapterView has been clicked, or null id no callback has been set.

public final HtcAdapterView.OnItemLongClickListener getOnItemLongClickListener ()

Since: API Level 2.0

Returns
  • The callback to be invoked with an item in this AdapterView has been clicked and held, or null id no callback as been set.

public final HtcAdapterView.OnItemSelectedListener getOnItemSelectedListener ()

Since: API Level 2.0

public int getPositionForView (View view)

Since: API Level 2.0

Gets the position within the adapter's data set for the view, where view is a an adapter item or a descendant of an adapter item.

Parameters
view An adapter item, or a descendant of an adapter item. This must be visible in this AdapterView at the time of the call.
Returns
  • The position within the adapter's data set of the view, or INVALID_POSITION if the view does not correspond to a list item (or it is not currently visible).

public Object getSelectedItem ()

Since: API Level 2.0

Returns
  • The data corresponding to the currently selected item, or null if there is nothing selected.

public long getSelectedItemId ()

Since: API Level 2.0

Returns
  • The id corresponding to the currently selected item, or INVALID_ROW_ID if nothing is selected.

public int getSelectedItemPosition ()

Since: API Level 2.0

Returns the position of the currently selected item within the adapter's data set

Returns
  • int Position (starting at 0), or INVALID_POSITION if there is nothing selected.

public abstract View getSelectedView ()

Since: API Level 2.0

Returns
  • The view corresponding to the currently selected item, or null if nothing is selected

public void onInitializeAccessibilityEvent (AccessibilityEvent event)

Since: API Level

public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Since: API Level

public boolean onRequestSendAccessibilityEvent (View child, AccessibilityEvent event)

Since: API Level

public boolean performItemClick (View view, int position, long id)

Since: API Level 2.0

Calls the OnItemClickListener, if it is defined.

Parameters
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.
Returns
  • True if there was an assigned OnItemClickListener that was called, false otherwise is returned.

public void removeAllViews ()

Since: API Level

This method is not supported and throws an UnsupportedOperationException when called.

Throws
UnsupportedOperationException Every time this method is invoked.

public void removeView (View child)

Since: API Level

This method is not supported and throws an UnsupportedOperationException when called.

Parameters
child Child view.
Throws
UnsupportedOperationException Every time this method is invoked.

public void removeViewAt (int index)

Since: API Level

This method is not supported and throws an UnsupportedOperationException when called.

Parameters
index Child index.
Throws
UnsupportedOperationException Every time this method is invoked.

public abstract void setAdapter (T adapter)

Since: API Level 2.0

Sets the adapter that provides the data and the views to represent the data in this widget.

Parameters
adapter The adapter to use to create this view's content.

public void setEmptyView (View emptyView)

Since: API Level 2.0

Sets the view to show if the adapter is empty

public void setFocusable (boolean focusable)

Since: API Level

public void setFocusableInTouchMode (boolean focusable)

Since: API Level

public void setListStyle (HtcAdapterView.ListStyle style)

Since: API Level 2.0

public void setOnClickListener (View.OnClickListener l)

Since: API Level

public void setOnItemClickListener (HtcAdapterView.OnItemClickListener listener)

Since: API Level 2.0

Registers a callback to be invoked when an item in this AdapterView has been clicked.

Parameters
listener The callback that will be invoked.

public void setOnItemLongClickListener (HtcAdapterView.OnItemLongClickListener listener)

Since: API Level 2.0

Registers a callback to be invoked when an item in this AdapterView has been clicked and held

Parameters
listener The callback that will run

public void setOnItemSelectedListener (HtcAdapterView.OnItemSelectedListener listener)

Since: API Level 2.0

Registers a callback to be invoked when an item in this AdapterView has been selected.

Parameters
listener The callback that will run

public abstract void setSelection (int position)

Since: API Level 2.0

Sets the currently selected item. To support accessibility subclasses that override this method must invoke the overriden super method first.

Parameters
position Index (starting at 0) of the data item to be selected.

Protected Methods

protected boolean canAnimate ()

Since: API Level

protected void dispatchRestoreInstanceState (SparseArray<Parcelable> container)

Since: API Level

Overrides to prevent thawing of any views created by the adapter.

protected void dispatchSaveInstanceState (SparseArray<Parcelable> container)

Since: API Level

Overrides to prevent freezing of any views created by the adapter.

protected void onDetachedFromWindow ()

Since: API Level

protected void onLayout (boolean changed, int left, int top, int right, int bottom)

Since: API Level 2.0