English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public abstract class

android.widget.CursorAdapter

java.lang.Object
android.widget.BaseAdapter Adapter GalleryAdapter ListAdapter
android.widget.CursorAdapter Filterable

Adapter that exposes data from a Cursor to a ListView widget. The Cursor must include a column named "_id" or this class will not work.

Known Direct Subclasses
Known Indirect Subclasses

Summary

Constants inherited from interface android.widget.Adapter

Fields

protected      boolean  mAutoRequery   
protected      ChangeObserver  mChangeObserver   
protected      Context  mContext   
protected      Cursor  mCursor   
protected      DataSetObserver  mDataSetObserver   
protected      boolean  mDataValid   
protected      int  mRowIDColumn   

Public Constructors

          CursorAdapter(Cursor c, Context context)
Constructor.
          CursorAdapter(Cursor c, Context context, boolean autoRequery)
Constructor

Public Methods

abstract        void  bindView(View view, Context context, Cursor cursor)
Bind an existing view to the data pointed to by cursor
        void  changeCursor(Cursor cursor)
Change the underlying cursor to a new cursor
        float  getAlpha(boolean focused, int offset)

Return the translucency of the specified item in the gallery.

    final    int  getCount()
        Cursor  getCursor()
Returns the cursor.
        View  getDropDownView(int position, View convertView, ViewGroup parent)

Get a View that displays in the drop down popup the data at the specified position in the data set.

        Filter  getFilter()

Returns a filter that can be used to constrain data with a filtering pattern.

    final    Object  getItem(int position)
    final    long  getItemId(int position)
        float  getScale(boolean focused, int offset)

Return the scale factor of the specified item in the gallery.

        View  getView(int position, View convertView, ViewGroup parent)
        View  newDropDownView(Context context, Cursor cursor, ViewGroup parent)
Makes a new drop down view to hold the data pointed to by cursor.
abstract        View  newView(Context context, Cursor cursor, ViewGroup parent)
Makes a new view to hold the data pointed to by cursor.
        boolean  stableIds()
Indicated whether the item ids are stable across changes to the underlying data.

Protected Methods

        String  convertToString(Cursor cursor)

Converts the cursor into a String.

        void  init(Cursor c, Context context, boolean autoRequery)
        Cursor  runQuery(CharSequence constraint)

Runs a query with the specified constraint.

Methods inherited from class android.widget.BaseAdapter
Methods inherited from class java.lang.Object
Methods inherited from interface android.widget.GalleryAdapter
Methods inherited from interface android.widget.ListAdapter
Methods inherited from interface android.widget.Filterable
Methods inherited from interface android.widget.SpinnerAdapter
Methods inherited from interface android.widget.Adapter

Details

Fields

protected boolean mAutoRequery

protected ChangeObserver mChangeObserver

protected Context mContext

protected Cursor mCursor

protected DataSetObserver mDataSetObserver

protected boolean mDataValid

protected int mRowIDColumn

Public Constructors

public CursorAdapter(Cursor c, Context context)

Constructor. The adapter will call requery() on the cursor whenever it changes so that the most recent data is always displayed.

Parameters

c The cursor from which to get the data.
context The context

public CursorAdapter(Cursor c, Context context, boolean autoRequery)

Constructor

Parameters

c The cursor from which to get the data.
context The context
autoRequery If true the adapter will call requery() on the cursor whenever it changes so the most recent data is always displayed.

Public Methods

public abstract void bindView(View view, Context context, Cursor cursor)

Bind an existing view to the data pointed to by cursor

Parameters

view Existing view, returned earlier by newView
context Interface to application's global information
cursor The cursor from which to get the data. The cursor is already moved to the correct position.

public void changeCursor(Cursor cursor)

Change the underlying cursor to a new cursor

Parameters

cursor the new cursor to be used

public float getAlpha(boolean focused, int offset)

Return the translucency of the specified item in the gallery.

public final int getCount()

See Also

public Cursor getCursor()

Returns the cursor.

Returns

  • the cursor.

public View getDropDownView(int position, View convertView, ViewGroup parent)

Get a View that displays in the drop down popup the data at the specified position in the data set.

public Filter getFilter()

Returns a filter that can be used to constrain data with a filtering pattern.

This method is usually implemented by Adapter classes.

public final Object getItem(int position)

See Also

public final long getItemId(int position)

See Also

public float getScale(boolean focused, int offset)

Return the scale factor of the specified item in the gallery.

public View getView(int position, View convertView, ViewGroup parent)

public View newDropDownView(Context context, Cursor cursor, ViewGroup parent)

Makes a new drop down view to hold the data pointed to by cursor.

Parameters

context Interface to application's global information
cursor The cursor from which to get the data. The cursor is already moved to the correct position.
parent The parent to which the new view is attached to

Returns

  • the newly created view.

public abstract View newView(Context context, Cursor cursor, ViewGroup parent)

Makes a new view to hold the data pointed to by cursor.

Parameters

context Interface to application's global information
cursor The cursor from which to get the data. The cursor is already moved to the correct position.
parent The parent to which the new view is attached to

Returns

  • the newly created view.

public boolean stableIds()

Indicated whether the item ids are stable across changes to the underlying data.

Protected Methods

protected String convertToString(Cursor cursor)

Converts the cursor into a String. Subclasses should override this method to convert their results. The default implementation returns an empty String for null values or the default String representation of the value.

Parameters

cursor the cursor to convert to a String

Returns

  • a String representing the value

protected void init(Cursor c, Context context, boolean autoRequery)

protected Cursor runQuery(CharSequence constraint)

Runs a query with the specified constraint. This query is requested by the filter attached to this adapter. The default implementation does not run any query and returns the current cursor. Subclasses should override this method to filter their results.

Contract: when constraint is null or empty, the original results, prior to any filtering, must be returned.

Parameters

constraint the constraint with which the query must be filtered

Returns

  • a Cursor representing the results of the new query

See Also

Build m5-rc15i - 10 Jun 2008 13:54