Tuesday, 22 January 2013

How Adapters works in Android

       An Adapter object acts as a bridge between a View and the underlying data for that view. The Adapter provides access to the data items. The Adapter is also responsible for making a View for each item in the data set.The adapter also defines how each row is theListView is displayed. 

Adapter implementations
       An adapter extend the BaseAdapter class. Android  provides some standard adapters; the most important are Array Adapter , Cursor Adapter , Simple CursorAdapter.
Array Adapter
It is an adapter of information for lists. It uses an array of objects. Array Adapter you use it in two ways:
>> ArrayAdapter TextView with array. (ArrayAdapter(Context context, int textViewResourceId, T[] objects).
>> ArrayAdapter TextView with list. (ArrayAdapter(Context context, int textViewResourceId, List<T> objects).
Cursor Adapter
      Basically Cursor is an interface. Cursor provides random read-write access to the result . Adapter that exposes data from a Cursor to a ListView widget.
Simple Cursor Adapter
   Basically Simple Cursor Adapter used to map columns from a cursor to TextViews or ImageViews defined in an XML file. You can specify which columns you want, which views you want to display the columns, and the XML file that defines the appearance of these views. The General format of this adapter is: SimpleCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to) . 

No comments:

Post a Comment