public class ListView
extends com.softwareag.mobile.runtime.nui.nUIContainerElement
implements com.softwareag.mobile.runtime.nui.nUIEventListener
A ListView
displays a given number of nUIDisplayObject
s,
typically subclasses of nUITableButton
s, in a vertically scrollable list.
Each of the nUIDisplayObject
s is referred to as a cell and represents one
row in the ListView
.
To create a ListView
a IListViewDelegate
needs to be provided.
Using the delegate the ListView
gets it's number of rows, cells for
given row indexes, paginations settings and separators. Delegates are also notified
of events on the cells. Overwrite notification methods in your delegate implementation
to handle events.
To create or update a ListView
call reload()
. This will remove
existing cells and recreate it's contents by again calling the
IListViewDelegate.getNumberOfRows(ListView)
and IListViewDelegate.getCell(ListView, int)
.
Between cells there might be a separator that again could be any subclass of
nUIDisplayObject
, but typically nUISeparatorElement
s would be used.
A ListView
might also have one header cell, that will always be the first
cell at the top. This cell is not removed on reload()
and is not counted as
row. You might use a header cell to add for example add a nUISearchEntry
.
If pagination is used, ListView
s will split the total number of rows into
pages with a maximum number of rows. This might be needed for large amounts of rows to
reduce load time. Pagination cells will be added automatically to navigate back and
forward, use IListViewDelegate.getPaginationNextPageCell(ListView, int)
and
IListViewDelegate.getPaginationPreviousPageCell(ListView, int)
to create the cells
with your content.
SAVED_POINTER_LOCATIONS
Y_IDENTIFIER_PREV_BOTTOM
COLOR_BACKGROUND_NORMAL, COLOR_BLACK, COLOR_FOREGROUND_DARK, COLOR_FOREGROUND_LIGHT, COLOR_FOREGROUND_NORMAL, COLOR_TRANSPARENT, COLOR_WHITE, DIMENSIONS_IDENTIFIER_PARENT_DIMENSIONS
event_listener, event_listener_exclusive, first_child, last_child, next_sibling, nuiid, parent, prev_sibling, unlink_children_on_removal_from_parent
bottom, center, centre, CREATE, CUSTOM_EVENT_CODE0, EVT_BACK_BUTTON, EVT_COMPLETED_EDIT, EVT_GAIN_FOCUS, EVT_LOSE_FOCUS, EVT_ON_ADDITION, EVT_POST_EDIT, EVT_PRE_EDIT, EVT_SWIPE_LEFT, EVT_SWIPE_RIGHT, EVT_TIMER_COMPLETE, EVT_TRANSITION_FROM_COMPLETE, EVT_TRIGGER, EVT_TRIGGER_HTTP_FAIL, EVT_TRIGGER_HTTP_SUCCESS, left, MAX_DY_FOR_SWIPE, MIN_DX_FOR_SWIPE, MIN_SCROLL_START_THRESHOLD, NO_YES, OFF_ON, POINTER_STATE_DRAGGED, POINTER_STATE_PRESSED, POINTER_STATE_PRESSED_AND_RELEASED, POINTER_STATE_RELEASED, REMOVE, right, size_absolute, size_huge, size_large, size_medium, size_relative, size_small, size_tiny, style_bold, style_default, style_italic, style_underlined, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, top
Constructor and Description |
---|
ListView(int nuiid,
IListViewDelegate delegate)
Creates a new
ListView with a given delegate. |
Modifier and Type | Method and Description |
---|---|
java.util.Vector |
allCells()
Returns all cell objects without header cell, pagination cell and separators.
|
com.softwareag.mobile.runtime.nui.nUIObject |
cellForRowIndex(int rowIndex)
Returns the cell for a given index in the
ListView . |
int |
getCurrentPaginationIndex()
Returns the current page index of the
ListView . |
IListViewDelegate |
getDelegate()
Call this method if you want the
IListViewDelegate that is currently
used by the ListView . |
com.softwareag.mobile.runtime.nui.nUIObject |
getHeaderElement()
Returns the current header cell used in the
ListView . |
int |
getMaxNumberOfRowsPerPage()
Returns the maximum number of rows used for pagination in the
ListView . |
boolean |
getUsesPagingation()
Returns the current pagination setting of the
ListView . |
boolean |
nUIEventCallback(com.softwareag.mobile.runtime.nui.nUIObject object,
int eventType)
Manages all events for the cells in the
ListView and forwards the
events to the delegate. |
void |
reload()
Call this method to reload the content of the
ListView . |
int |
rowIndexForCell(com.softwareag.mobile.runtime.nui.nUIObject cell)
Returns the given cell's (row) index in the
ListView . |
void |
setCurrentPaginationIndex(int index)
Call this method with a new index to change the pagination index.
|
void |
setDelegate(IListViewDelegate delegate)
Call this method if you want to set a new
IListViewDelegate . |
void |
setHeaderElement(com.softwareag.mobile.runtime.nui.nUIObject headerElement)
Call this method to set a new header cell for the
ListView . |
getHscrollable, getScreenInnerX, getScreenInnerY, getVscrollable, insertAt, setHscrollable, setVscrollable
getBottom, getFocus, getFocusable, getHeight, getInnerHeight, getInnerWidth, getInnerX, getInnerY, getLeft, getMaxChildX, getMaxChildY, getRight, getScreenX, getScreenY, getTop, getTopLevelParentView, getTopLevelParentWindow, getTriggerable, getWidth, getX, insertAtInternal, remove, setBottom, setChildFocus, setFocus, setFocusable, setHeight, setInnerHeight, setInnerWidth, setInnerX, setInnerY, setLeft, setRight, setTop, setTriggerable, setWidth, setX, setY
public ListView(int nuiid, IListViewDelegate delegate)
ListView
with a given delegate. It is important to
provide a IListViewDelegate
when creating the ListView
,
because reload()
will be automatically called to create and display
cells.public void reload()
Call this method to reload the content of the ListView
. When reloaded,
first all existing cells are removed (except header cells) and
IListViewDelegate.getNumberOfRows(ListView)
is called to get the new number of
cells (rows) to be displayed. For each row IListViewDelegate.getCell(ListView, int)
is called again with the current index
You typically invoke this method if your data model changed and cells need to be recreated or updated to reflect the changes in the UI. Make sure to only reload if really needed, this will recreate all the cells.
public int rowIndexForCell(com.softwareag.mobile.runtime.nui.nUIObject cell)
Returns the given cell's (row) index in the ListView
. For index
calculation only cells are used, header and separators do not have rowIndexes
.
Call this method in combination with cellForRowIndex(int)
.
Please note, nUIObject.childIndexOf(nUIObject)
will not necessarily return the
same index.
cell
- the cell object you want to get the index forListView
public com.softwareag.mobile.runtime.nui.nUIObject cellForRowIndex(int rowIndex)
Returns the cell for a given index in the ListView
. Only use
rowIndexForCell(nUIObject)
to get the row index of a cell.
Please note, nUIObject.childElementAt(int)
will not necessarily return the
same index
rowIndex
- the index of a cell (row) you want the cell object forpublic java.util.Vector allCells()
Returns all cell objects without header cell, pagination cell and separators.
public IListViewDelegate getDelegate()
Call this method if you want the IListViewDelegate
that is currently
used by the ListView
. If not set, null
will be returned.
ListView
IListViewDelegate
or null
public void setDelegate(IListViewDelegate delegate)
Call this method if you want to set a new IListViewDelegate
. All
following calls of the ListView
to it's delegate will use the
new instance. Make sure to provide a delegate when creating the ListView
instance by using ListView(int, IListViewDelegate)
constructor.
public com.softwareag.mobile.runtime.nui.nUIObject getHeaderElement()
Returns the current header cell used in the ListView
. The header cell
will always be the first cell, but will scroll vertically! If you need to have a
static, not scrolling, header above the scrollable list of cells
null
public void setHeaderElement(com.softwareag.mobile.runtime.nui.nUIObject headerElement)
Call this method to set a new header cell for the ListView
. The new
header cell will replace an existing one. It will always be the first cell in the
ListView
and does not have a row index. Use getHeaderElement()
to access the current cell instead. Header cells do scroll with all other cells,
it is not statically bound to the top of the ListView
.
headerElement
- the new header cell to be used or null
to remove
the current cell in usepublic boolean getUsesPagingation()
Returns the current pagination setting of the ListView
. If pagination
is used, getMaxNumberOfRowsPerPage()
is called to determine the maximum
number of rows to be displayed in the ListView
and the total number
of cells will be split into pages with the given getMaxNumberOfRowsPerPage()
.
To navigate the pages, the ListView
will automatically add cells to go
back or forward one. To configure the cells to be used for navigation, use
IListViewDelegate.getPaginationPreviousPageCell(ListView, int)
and
IListViewDelegate.getPaginationNextPageCell(ListView, int)
.
true
if pagination is enabled, false
if notpublic int getMaxNumberOfRowsPerPage()
Returns the maximum number of rows used for pagination in the ListView
.
To change the value, use IListViewDelegate.getMaxNumberPaginationRows(ListView)
.
public int getCurrentPaginationIndex()
Returns the current page index of the ListView
. This index changes automatically
as the user navigates the list.
ListView
public void setCurrentPaginationIndex(int index)
Call this method with a new index to change the pagination index. You need to call
reload()
after changing the pagination index to make the ListView
actually change to the new index.
index
- the new index of the page to be used.public boolean nUIEventCallback(com.softwareag.mobile.runtime.nui.nUIObject object, int eventType)
Manages all events for the cells in the ListView
and forwards the
events to the delegate.
nUIEventCallback
in interface com.softwareag.mobile.runtime.nui.nUIEventListener
object
- The object causing the eventeventType
- The type of eventtrue
if the event was handled, false
if it
was not handled