java.lang.Object | ||
↳ | android.widget.BaseAdapter | |
↳ | android.widget.CursorAdapter |
Known Direct Subclasses |
Known Indirect Subclasses |
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.
Additionally, using MergeCursor
with this class will
not work if the merged Cursors have overlapping values in their "_id"
columns.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FLAG_AUTO_REQUERY |
This constant was deprecated
in API level 11.
This option is discouraged, as it results in Cursor queries
being performed on the application's UI thread and thus can cause poor
responsiveness or even Application Not Responding errors. As an alternative,
use LoaderManager with a CursorLoader .
|
|||||||||
int | FLAG_REGISTER_CONTENT_OBSERVER |
If set the adapter will register a content observer on the cursor and will call
onContentChanged() when a notification comes in.
|
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.widget.Adapter
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This constructor was deprecated
in API level 11.
This option is discouraged, as it results in Cursor queries
being performed on the application's UI thread and thus can cause poor
responsiveness or even Application Not Responding errors. As an alternative,
use
LoaderManager with a CursorLoader .
| |||||||||||
Constructor that allows control over auto-requery.
| |||||||||||
Recommended constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Bind an existing view to the data pointed to by cursor
| |||||||||||
Change the underlying cursor to a new cursor.
| |||||||||||
Converts the cursor into a CharSequence. | |||||||||||
How many items are in the data set represented by this Adapter.
| |||||||||||
Returns the cursor.
| |||||||||||
Gets a
View that displays in the drop down popup
the data at the specified position in the data set.
| |||||||||||
Returns the value previously set by a call to
setDropDownViewTheme(Theme) .
| |||||||||||
Returns a filter that can be used to constrain data with a filtering pattern. | |||||||||||
Returns the query filter provider used for filtering.
| |||||||||||
Get the data item associated with the specified position in the data set.
| |||||||||||
Get the row id associated with the specified position in the list.
| |||||||||||
Get a View that displays the data at the specified position in the data set.
| |||||||||||
Indicates whether the item ids are stable across changes to the
underlying data.
| |||||||||||
Makes a new drop down view to hold the data pointed to by cursor.
| |||||||||||
Makes a new view to hold the data pointed to by cursor.
| |||||||||||
Runs a query with the specified constraint.
| |||||||||||
Sets the
Resources.Theme against which drop-down views are
inflated.
| |||||||||||
Sets the query filter provider used to filter the current Cursor.
| |||||||||||
Swap in a new Cursor, returning the old Cursor.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method was deprecated
in API level 11.
Don't use this, use the normal constructor. This will
be removed in the future.
| |||||||||||
Called when the
ContentObserver on the cursor receives a change notification.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.BaseAdapter
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.widget.ListAdapter
| |||||||||||
From interface
android.widget.SpinnerAdapter
| |||||||||||
From interface
android.widget.Filterable
| |||||||||||
From interface
android.widget.ThemedSpinnerAdapter
| |||||||||||
From interface
android.widget.Adapter
|
This constant was deprecated
in API level 11.
This option is discouraged, as it results in Cursor queries
being performed on the application's UI thread and thus can cause poor
responsiveness or even Application Not Responding errors. As an alternative,
use LoaderManager
with a CursorLoader
.
If set the adapter will call requery() on the cursor whenever a content change
notification is delivered. Implies FLAG_REGISTER_CONTENT_OBSERVER
.
If set the adapter will register a content observer on the cursor and will call
onContentChanged()
when a notification comes in. Be careful when
using this flag: you will need to unset the current Cursor from the adapter
to avoid leaks due to its registered observers. This flag is not needed
when using a CursorAdapter with a
CursorLoader
.
This constructor was deprecated
in API level 11.
This option is discouraged, as it results in Cursor queries
being performed on the application's UI thread and thus can cause poor
responsiveness or even Application Not Responding errors. As an alternative,
use LoaderManager
with a CursorLoader
.
Constructor that always enables auto-requery.
context | The context |
---|---|
c | The cursor from which to get the data. |
Constructor that allows control over auto-requery. It is recommended
you not use this, but instead CursorAdapter(Context, Cursor, int)
.
When using this constructor, FLAG_REGISTER_CONTENT_OBSERVER
will always be set.
context | The context |
---|---|
c | The cursor from which to get the data. |
autoRequery | If true the adapter will call requery() on the cursor whenever it changes so the most recent data is always displayed. Using true here is discouraged. |
Recommended constructor.
context | The context |
---|---|
c | The cursor from which to get the data. |
flags | Flags used to determine the behavior of the adapter; may
be any combination of FLAG_AUTO_REQUERY and
FLAG_REGISTER_CONTENT_OBSERVER .
|
Bind an existing view to the data pointed to by cursor
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. |
Change the underlying cursor to a new cursor. If there is an existing cursor it will be closed.
cursor | The new cursor to be used |
---|
Converts the cursor into a CharSequence. 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.
cursor | the cursor to convert to a CharSequence |
---|
How many items are in the data set represented by this Adapter.
Gets a View
that displays in the drop down popup
the data at the specified position in the data set.
position | index of the item whose view we want. |
---|---|
convertView | the old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view. |
parent | the parent that this view will eventually be attached to |
View
corresponding to the data at the
specified position.
Returns the value previously set by a call to
setDropDownViewTheme(Theme)
.
Resources.Theme
against which drop-down views are
inflated, or null
if one has not been explicitly set
Returns a filter that can be used to constrain data with a filtering pattern.
This method is usually implemented by Adapter
classes.
Returns the query filter provider used for filtering. When the provider is null, no filtering occurs.
Get the data item associated with the specified position in the data set.
position | Position of the item whose data we want within the adapter's data set. |
---|
Get the row id associated with the specified position in the list.
position | The position of the item within the adapter's data set whose row id we want. |
---|
Get a View that displays the data at the specified position in the data set. You can either
create a View manually or inflate it from an XML layout file. When the View is inflated, the
parent View (GridView, ListView...) will apply default layout parameters unless you use
inflate(int, android.view.ViewGroup, boolean)
to specify a root view and to prevent attachment to the root.
position | The position of the item within the adapter's data set of the item whose view we want. |
---|---|
convertView | The old view to reuse, if possible. Note: You should check that this view
is non-null and of an appropriate type before using. If it is not possible to convert
this view to display the correct data, this method can create a new view.
Heterogeneous lists can specify their number of view types, so that this View is
always of the right type (see getViewTypeCount() and
getItemViewType(int) ). |
parent | The parent that this view will eventually be attached to |
Indicates whether the item ids are stable across changes to the underlying data.
Makes a new drop down view to hold the data pointed to by cursor.
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 |
Makes a new view to hold the data pointed to by cursor.
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 |
Runs a query with the specified constraint. This query is requested
by the filter attached to this adapter.
The query is provided by a
FilterQueryProvider
.
If no provider is specified, the current cursor is not filtered and returned.
After this method returns the resulting cursor is passed to changeCursor(Cursor)
and the previous cursor is closed.
This method is always executed on a background thread, not on the
application's main thread (or UI thread.)
Contract: when constraint is null or empty, the original results,
prior to any filtering, must be returned.
constraint | the constraint with which the query must be filtered |
---|
Sets the Resources.Theme
against which drop-down views are
inflated.
By default, drop-down views are inflated against the theme of the
Context
passed to the adapter's constructor.
theme | the theme against which to inflate drop-down views or
null to use the theme from the adapter's context |
---|
Sets the query filter provider used to filter the current Cursor.
The provider's
runQuery(CharSequence)
method is invoked when filtering is requested by a client of
this adapter.
filterQueryProvider | the filter query provider or null to remove it |
---|
Swap in a new Cursor, returning the old Cursor. Unlike
changeCursor(Cursor)
, the returned old Cursor is not
closed.
newCursor | The new cursor to be used. |
---|
This method was deprecated
in API level 11.
Don't use this, use the normal constructor. This will
be removed in the future.
Called when the ContentObserver
on the cursor receives a change notification.
The default implementation provides the auto-requery logic, but may be overridden by
sub classes.