public class ListView
extends com.softwareag.mobile.runtime.nui.nUIContainerElement
implements com.softwareag.mobile.runtime.nui.nUIEventListener
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_DOUBLE_TAP, EVT_GAIN_FOCUS, EVT_LONG_PRESS, EVT_LOSE_FOCUS, EVT_ON_ADDITION, EVT_PICKER_CANCEL, EVT_PICKER_OK, 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, GESTURE_DOUBLE_TAP, GESTURE_LONG_PRESS, GESTURE_NONE, GESTURE_SWIPE, 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.
|
java.lang.Object |
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 . |
int |
getRowHeight()
Deprecated.
The native property is no longer supported. Please use the new
ListView.
|
boolean |
getUsesPagingation()
Returns the current pagination setting of the
ListView . |
void |
insertRowIndex(int row)
Inserts a new cell at the passed index.
Delegates to insertRowIndexes(int[]) . |
void |
insertRowIndexes(int[] rows)
Inserts new cells at the indexes passed in
rows |
void |
insertRowIndexes(int rowIndex,
int numberOfRows)
Inserts a number of cells beginning at the provided
rowIndex
|
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 |
onRemoved()
Overwritten to clear the list view delegate.
|
void |
reload()
Call this method to reload the content of the
ListView . |
void |
reloadRowIndex(int row)
Reloads the cell at the passed index
row . |
void |
reloadRowIndexes(int[] rows)
Reloads all cells at the passed indexes.
|
void |
removeAllElements()
Removes all cells and clears the underlying cache.
|
void |
removeRowIndex(int row)
Removes a cell at the passed index.
|
void |
removeRowIndexes(int[] rows)
Removes all cells provided by the passed indexes.
|
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 . |
void |
setRowHeight(int rowHeight)
Deprecated.
The native property is no longer supported. Please use the new
ListView.
|
void |
setSelectionFromTop(int index,
int offsetY)
Deprecated.
The native property is no longer supported. Please use the new
ListView.
|
void |
setSortEnabled(boolean enabled)
Deprecated.
The native property is no longer supported. Please use the new
ListView.
|
getBgimageScroll, getHscrollable, getScreenInnerX, getScreenInnerY, getVscrollable, insertAt, setBgimageScroll, setHscrollable, setVscrollable
applyBackground, applyBackground, applyBackground
getBackgroundDrawable, getBgcolor, getBottom, getElementIdentifier, getFocus, getFocusable, getGesturable, getHeight, getInnerHeight, getInnerWidth, getInnerX, getInnerY, getLeft, getMaxChildX, getMaxChildY, getProperties, getProperty, getRight, getScreenX, getScreenY, getTop, getTopLevelParentView, getTopLevelParentWindow, getTriggerable, getWidth, getX, getY, insertAtInternal, isEnabled, isVisible, remove, setBackgroundDrawable, setBgcolor, setBottom, setChildFocus, setElementIdentifier, setEnabled, setFocus, setFocusable, setGesturable, setHeight, setInnerHeight, setInnerWidth, setInnerX, setInnerY, setLeft, setProperties, setProperty, setRight, setTop, setTriggerable, setVisible, 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.nuiid
- delegate
- public void reload()
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 void reloadRowIndex(int row)
row
- public void reloadRowIndexes(int[] rows)
rows
- public void insertRowIndex(int row)
insertRowIndexes(int[])
.row
- insertRowIndexes(int, int)
public void insertRowIndexes(int rowIndex, int numberOfRows)
rowIndex
rowIndex
- numberOfRows
- insertRowIndexes(int, int)
public void insertRowIndexes(int[] rows)
rows parameter.
For every index IListViewDelegate.getCell(ListView, int)
will be called
passing the index to the delegate to create a new instance of the
nUIDisplayObject
to be inserted.
The indexes must be greater than or equal to 0 and less than or equal to
the current number of elements managed by the ListView plus the number of indexes
to be inserted. In case the index equals the latter condition the element is
added (appended) to the ListView. Indexes to be inserted must also be ordered
increasing, e.g. new int[] {0,2,3,5}
. An
IndexOutOfBoundsException
will be thrown if indexes do not match
those conditions.
rows
- the indexes starting with 0 of the rows to be instertedjava.lang.IndexOutOfBoundsException
- if indexes are out of rangepublic void removeRowIndex(int row)
removeRowIndexes(int[])
.row
- public void removeRowIndexes(int[] rows)
rows
- public void removeAllElements()
setHeaderElement(nUIObject)
with null
as parameter
value.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 java.lang.Object cellForRowIndex(int rowIndex)
ListView
. Only use
rowIndexForCell(nUIObject)
to get the row index of a cell. Please
note, nUIObject.childElementAt(int)
will not necessarily return the
same indexrowIndex
- the index of a cell (row) you want the cell object forpublic void setSelectionFromTop(int index, int offsetY)
ListView
scrolls to the cell, correspondent by the passed index, if this cell isn't in
the ListView
's visible area.
This method has only an effect by using the native ListView
feature.
index
- offsetY
- public java.util.Vector allCells()
public IListViewDelegate getDelegate()
IListViewDelegate
that is currently
used by the ListView
. If not set, null
will be
returned.ListView
IListViewDelegate
or
null
public void setDelegate(IListViewDelegate delegate)
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.delegate
- public int getRowHeight()
This method has only an effect by using the native ListView
feature.
public void setRowHeight(int rowHeight)
rowHeight
for each cell based on the passed positive
integer value. The method is only implemented for native
ListView
s on iOS. Use this method to globally set the
rowHeight
for each cell. This will have an performance advantage
by using a huge amount of cells (>200).
This method has only an effect by using the native ListView
feature.
rowHeight
- public com.softwareag.mobile.runtime.nui.nUIObject getHeaderElement()
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 cellsnull
.public void setHeaderElement(com.softwareag.mobile.runtime.nui.nUIObject headerElement)
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()
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()
ListView
. To change the value, use
IListViewDelegate.getMaxNumberPaginationRows(ListView)
.public int getCurrentPaginationIndex()
ListView
. This index
changes automatically as the user navigates the list.ListView
public void setCurrentPaginationIndex(int index)
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 void setSortEnabled(boolean enabled)
ListView
. Make sure to implement the delegate methods for
managing manual sorting.
This method has only an effect by using the native ListView
feature.
enabled
- true
if sorting should be enabled, false
if sorting should be disabledpublic boolean nUIEventCallback(com.softwareag.mobile.runtime.nui.nUIObject object, int eventType)
ListView
and forwards
the events to the delegate.nUIEventCallback
in interface com.softwareag.mobile.runtime.nui.nUIEventListener
true
if the event was handled, false
if it
was not handledpublic void onRemoved()
If this method is overwritten, clients need to make sure to call the super method, othwerwise memory leaks are possible.
onRemoved
in class com.softwareag.mobile.runtime.nui.nUIDisplayObject