net.rim.device.api.ui.component
Interface ListFieldCallback

All Known Implementing Classes:
ObjectListField

public interface ListFieldCallback

Classes implement this interface to provide callback functionality to handle ListField drawing. A ListField uses a class that implements the ListFieldCallback interface to perform drawing tasks. A ListField must register a class that implements the ListFieldCallback interface using the setCallback method before the class can be used. After registration, When a ListField must display a particular item in its list, it invokes the appropriate methods of the registered callback class.


Method Summary
 void drawListRow(ListField listField, Graphics graphics, int index, int y, int width)
          Invoked when a particular row requires painting.
 Object get(ListField listField, int index)
          Retrieves an item from list.
 int getPreferredWidth(ListField listField)
          Retrieves this list field's preferred width.
 int indexOfList(ListField listField, String prefix, int start)
          Retrieves first occurence of prefix in list.
 

Method Detail

drawListRow

public void drawListRow(ListField listField,
                        Graphics graphics,
                        int index,
                        int y,
                        int width)
Invoked when a particular row requires painting.

The graphics context passed to this method represents the entire list, not just the row for repainting. Accordingly, the y parameter indicates how far down in the list the repaint should occur.

Parameters:
listField - List field that requires repainting.
graphics - Graphics context for the list.
index - Row index to display.
y - Distance from the top of the list field at which to start painting.
width - Width of the field.

get

public Object get(ListField listField,
                  int index)
Retrieves an item from list.

Provided a list field and a row index, this method returns the object contained in that row.

Parameters:
listField - List field to search through.
index - Row index containing desired item.
Returns:
Object from list.

getPreferredWidth

public int getPreferredWidth(ListField listField)
Retrieves this list field's preferred width.

Returns the list field's preferred width for layout purposes. Typically, this width is the same as the width of the widest item in the contained list.

Parameters:
listField - List field for which to determine preferred width.
Returns:
Preferred width (number of pixels) for the list.

indexOfList

public int indexOfList(ListField listField,
                       String prefix,
                       int start)
Retrieves first occurence of prefix in list.

Provided a list, a string prefix, and a start index, this method returns the index of the first item that matches against the string prefix (that is, a string prefix of foo matches a list item of foobar).

If a match can be found between the start index and the end of the list, this method should return the index of that matching item.

If a match can not be found between the start index and the end of the list, this method should return ListField.getSelectedIndex().

If this type of search is not applicable to the list, this method should return -1.

Parameters:
listField - List field in which to search.
prefix - Prefix to search for.
start - List item at which commence the search.
Returns:
Results of the search (see method description).



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.