T
- Type of item to put in the listpublic class SearchAdapter<T extends Listable>
extends android.widget.ArrayAdapter<T>
implements android.widget.Filterable
Modifier and Type | Class and Description |
---|---|
(package private) class |
SearchAdapter.HolderItem
Keeping views accessible saves calls to findViewById, which is a performance bottleneck.
|
Modifier and Type | Field and Description |
---|---|
private android.content.Context |
context
Context which holds the list |
private android.widget.Filter |
filter
Filters list items based on queries
|
private java.util.List<T> |
items
List of items to display
|
private int |
listViewID
ID of the UI element that is the list
|
Constructor and Description |
---|
SearchAdapter(android.content.Context context,
int resource,
int listViewID)
Initialize context variables without a starting list
|
SearchAdapter(android.content.Context context,
int resource,
int listViewID,
java.util.List<T> items)
Initialize instance fields with provided parameters
|
Modifier and Type | Method and Description |
---|---|
void |
addAll(java.util.Collection<? extends T> collection)
Add all items in a
Collection to the list of items the adapter displays in the list |
void |
clear()
Clears the list of all items
|
T |
getItem(int position)
Get the item associated with the list entry at a certain position
|
android.view.View |
getView(int position,
android.view.View convertView,
android.view.ViewGroup parent)
Get a
View for the list |
add, addAll, createFromResource, getAutofillOptions, getContext, getCount, getDropDownView, getDropDownViewTheme, getFilter, getItemId, getPosition, insert, notifyDataSetChanged, remove, setDropDownViewResource, setDropDownViewTheme, setNotifyOnChange, sort
areAllItemsEnabled, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetInvalidated, registerDataSetObserver, setAutofillOptions, unregisterDataSetObserver
private android.content.Context context
Context
which holds the listprivate int listViewID
private android.widget.Filter filter
public SearchAdapter(android.content.Context context, int resource, int listViewID, java.util.List<T> items)
context
- resource
- listViewID
- Identifier for list the adapter will populateitems
- SearchAdapter(android.content.Context context, int resource, int listViewID)
context
- application contextresource
- int resource layout idpublic T getItem(int position)
public android.view.View getView(int position, android.view.View convertView, android.view.ViewGroup parent)
View
for the listgetView
in interface android.widget.Adapter
getView
in class android.widget.ArrayAdapter<T extends Listable>
position
- Position of list element to get the View
forconvertView
- View
inflated from R.layout#network_list_item
that will
represent the list entryparent
- Parent of the created View
View
for an element of the listpublic void addAll(java.util.Collection<? extends T> collection)
Collection
to the list of items the adapter displays in the list