BaseAdapter as the name suggests BaseAdapter
is a base adapter, or super adapter. An adapter is a class that acts as a bridge between an adapterview and the underlying data source.
By being a base adapter BaseAdapter
provides a common implementation for adapters that can be used in:
- ListView,GridView – By use of listAdapter.
- Spinner – By use of spinnerAdapter.
BaseAdapter Details
- BaseAdapter was introduced back in Android API level 1.
- It’s actually an abstract class in that it has some abstract methods that need overriding. Therefore you have to either choose to implement those methods or make your child class as well.
public abstract class BaseAdapter ..{}
- BaseAdapter derives from java.lang.Object.
public abstract class BaseAdapter extends Object ...{}
- BaseAdapter implements ListAdapter and SpinnerAdapter. SpinnerAdapter is used for spinners while ListAdapter for ListViews and GridViews.
public abstract class BaseAdapter extends Object implements ListAdapter, SpinnerAdapter{..}
BaseAdapter Children and GrandChildren
BaseAdapter has several direct and indirect sub-classes.
No. | Class | Type | Description |
---|---|---|---|
1. | ArrayAdapter | Direct | While BaseAdapter is always abstract, this is a concrete implementation of BaseAdapter backed by an array of arbitrary objects. |
2. | SimpleAdapter | Direct | A BaseAdapter child we can use to provide mapping between static data to views defined in XML file. |
3. | CursorAdapter | Direct | A BaseAdapter child that exposes data from a cursor to a ListView. |
4. | ResourceCursorAdapter | Indirect | A CursorAdapter child that creates views defined in an XML file. |
5. | SimpleCursorAdapter | Indirect | A a ResourceCursorAdapter child that can map columns from Cursor or TextViews or ImageViews defined in an XML file. |
Oclemy
Android Custom Filter/Search ListView With Images Text [BaseAdapter]
Hello good people,We cover how to perform a Custom Filter against data in your ListView.Our adapter is BaseAdapter and we shall be searching ListView with images and text.We shall implement Filterable interface and derive from Filter class.
PLATFORM : Android Java
TOOLS : Eclipse,Bluestacks Emulator
SECTION 1 : Our Player Class.
Purpose :
SECTION 2 : Our Custom Adapter class
Purpose:
SECTION 3: Our MainActivity class:
Purpose :
SECTION 4 : Our ActivityMain.xml layout
Purpose :
SECTION 4: Our Model.xml Layout Purpose :
Good day.