com.sibvisions.android.widget
Class DataBookAdapter

java.lang.Object
  extended by android.widget.BaseAdapter
      extended by com.sibvisions.android.widget.DataBookAdapter
All Implemented Interfaces:
Adapter, ListAdapter, SpinnerAdapter, IControl

public class DataBookAdapter
extends BaseAdapter
implements IControl

The DataBookAdapter is a BaseAdapter which gets data from an IDataBook implementation. It supports ListView and Spinner. The adapter uses the first primary key column to identify the item. Ensure that the primary key column is set. The display values will be read from the table columns of the databook. If you didn't specify special column view resource ids, then the first column of the table columns will be set into the first found view (Text, Image, Checkbox). If you specified the column view resource ids, then the columns out of the table columns will be used in the same order as the column view resource ids were set.


Nested Class Summary
static interface DataBookAdapter.ValueFormatter
          The ValueFormatter allows changing the value before it will be set to a view.
 
Field Summary
 
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
 
Fields inherited from interface android.widget.Adapter
IGNORE_ITEM_VIEW_TYPE, NO_SELECTION
 
Constructor Summary
DataBookAdapter(Context pContext, IDataBook pDataBook, int pLayout)
          Creates a new instance of DataBookAdapter for a specific context and layout.
 
Method Summary
protected  void bindView(View pView, int pPosition)
          Binds an existing view to the data pointed to by databook.
 void cancelEditing()
          
protected  View createDropDownView(ViewGroup pParent)
          Creates a new dropdown view to hold the data pointed to by databook.
protected  View createView(ViewGroup pParent)
          Creates a new view to hold the data pointed to by databook.
 int[] getColumnViewResources()
          Gets the resource ids of views which should be filled with values from the databook.
protected  Context getContext()
          Gets the applications global information.
 int getCount()
          
 IDataBook getDataBook()
          Gets the databook.
 View getDropDownView(int pPosition, View pConvertView, ViewGroup pParent)
          
 IChangeableDataRow getItem(int pPosition)
          
 long getItemId(int pPosition)
          
 TranslationMap getTranslation()
          
 DataBookAdapter.ValueFormatter getValueFormatter()
          Gets the current value formatter.
 View getView(int pPosition, View pConvertView, ViewGroup pParent)
          
 void notifyRepaint()
          
 void saveEditing()
          
 void setColumnViewResources(int[] pViewResourceIds)
          Sets the resource ids of views which should be filled with values from the databook.
 void setDataBook(IDataBook pDataBook)
          Sets the databook and updates the dataset.
 void setDropDownViewResource(int pLayoutDropDown)
          Sets the layout resource of the drop down views.
 void setTranslation(TranslationMap pTranslation)
          
 void setValueFormatter(DataBookAdapter.ValueFormatter pFormatter)
          Sets the formatter to change values before they will be set to a view.
 void setViewResource(int pLayout)
          Sets the layout resource of the item views.
 
Methods inherited from class android.widget.BaseAdapter
areAllItemsEnabled, getItemViewType, getViewTypeCount, hasStableIds, isEmpty, isEnabled, notifyDataSetChanged, notifyDataSetInvalidated, registerDataSetObserver, unregisterDataSetObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataBookAdapter

public DataBookAdapter(Context pContext,
                       IDataBook pDataBook,
                       int pLayout)
Creates a new instance of DataBookAdapter for a specific context and layout.

Parameters:
pContext - interface to application's global information
pDataBook - the databook
pLayout - the item layout
Method Detail

notifyRepaint

public void notifyRepaint()

Specified by:
notifyRepaint in interface IControl

saveEditing

public void saveEditing()

Specified by:
saveEditing in interface IControl

cancelEditing

public void cancelEditing()

Specified by:
cancelEditing in interface IControl

setTranslation

public void setTranslation(TranslationMap pTranslation)

Specified by:
setTranslation in interface IControl

getTranslation

public TranslationMap getTranslation()

Specified by:
getTranslation in interface IControl

getCount

public int getCount()

Specified by:
getCount in interface Adapter

getItem

public IChangeableDataRow getItem(int pPosition)

Specified by:
getItem in interface Adapter

getItemId

public long getItemId(int pPosition)

Specified by:
getItemId in interface Adapter

getView

public View getView(int pPosition,
                    View pConvertView,
                    ViewGroup pParent)

Specified by:
getView in interface Adapter

getDropDownView

public View getDropDownView(int pPosition,
                            View pConvertView,
                            ViewGroup pParent)

Specified by:
getDropDownView in interface SpinnerAdapter
Overrides:
getDropDownView in class BaseAdapter

setDataBook

public void setDataBook(IDataBook pDataBook)
Sets the databook and updates the dataset.

Parameters:
pDataBook - the databook or null to unset the databook

getDataBook

public IDataBook getDataBook()
Gets the databook.

Returns:
the databook or null if no databook is set

setViewResource

public void setViewResource(int pLayout)
Sets the layout resource of the item views.

Parameters:
pLayout - the layout resources used to create item views

setDropDownViewResource

public void setDropDownViewResource(int pLayoutDropDown)
Sets the layout resource of the drop down views.

Parameters:
pLayoutDropDown - the layout resources used to create drop down views

getContext

protected Context getContext()
Gets the applications global information.

Returns:
the information context

createView

protected View createView(ViewGroup pParent)
Creates a new view to hold the data pointed to by databook.

Parameters:
pParent - the parent to which the new view is attached to
Returns:
the newly created view.

createDropDownView

protected View createDropDownView(ViewGroup pParent)
Creates a new dropdown view to hold the data pointed to by databook.

Parameters:
pParent - the parent to which the new view is attached to
Returns:
the newly created view.

setColumnViewResources

public void setColumnViewResources(int[] pViewResourceIds)
Sets the resource ids of views which should be filled with values from the databook.

Parameters:
pViewResourceIds - the resource ids within a layout

getColumnViewResources

public int[] getColumnViewResources()
Gets the resource ids of views which should be filled with values from the databook.

Returns:
the resource ids within a layout

bindView

protected void bindView(View pView,
                        int pPosition)
Binds an existing view to the data pointed to by databook.

Parameters:
pView - existing view, returned earlier by createView
pPosition - the row of the databook

setValueFormatter

public void setValueFormatter(DataBookAdapter.ValueFormatter pFormatter)
Sets the formatter to change values before they will be set to a view.

Parameters:
pFormatter - the formatter or null to unset

getValueFormatter

public DataBookAdapter.ValueFormatter getValueFormatter()
Gets the current value formatter.

Returns:
the formatter or null if no formatter will be used


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.