public class ListContainer extends ScrollContainer
The correct way to create a ListContainer item is by subclassing a
Container and adding the controls in the initUI method. Adding
directly using getContainer(i).add
will not work. Below is
an example of how to use it, taken from the UIGadgets sample.
class LCItem extends ScrollContainer { Label lDate,lPrice,lDesc; Check chPaid; public LCItem() { super(false); // VERY IMPORTANT (a RuntimeException will be thrown if this is not used). } public void initUI() { add(chPaid = new Check("Paid"),LEFT,TOP); add(lDate = new Label("99/99/9999"),RIGHT,TOP); add(new Label("US$"),LEFT,AFTER); add(lPrice = new Label("999.999.99"),AFTER,SAME); add(lDesc = new Label("",RIGHT),AFTER+10,SAME); lDesc.setText("description"); } } private void testListContainer() { ListContainer lc; add(lc = new ListContainer(),LEFT,TOP,FILL,FILL); for (int i =0; i < 10; i++) lc.addContainer(new LCItem()); }When an item is selected, a PRESSED event is dispatched. Check the ListContainerSample in the sdk for a bunch of ideas of what can be done with this component. The ListContainer supports navigation using the keys up/down, page-up/down, and enter. The left and right keys acts like clicking in the left or right buttons (if any).
Modifier and Type | Class and Description |
---|---|
static class |
ListContainer.Item
An item of the ListContainer.
|
class |
ListContainer.Layout
A set of fields and default fields that will be used to define the layout of a ListContainer's Item.
|
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
boolean |
drawHLine
If true (default), draws a horizontal line between each container.
|
int |
highlightColor
Color used to highlight a container.
|
protected Container |
lastSel |
protected int |
lastSelBack |
protected int |
lastSelIndex |
autoScroll, bag, bag0, disabledFlick, flick, hsIgnoreAutoScroll, lastH, lastV, sbH, sbV, shrink2size
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastScreenWidth, lastW, lastX, lastY, numChildren, started, tabOrder, tail, TRANSITION_TIME
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
Constructor and Description |
---|
ListContainer() |
Modifier and Type | Method and Description |
---|---|
void |
addContainer(Container c)
Adds a new Container to this list.
|
void |
addContainers(Container[] all)
Adds an array of Containers to this list.
|
Container |
getContainer(int idx)
Returns the given container number or null if its invalid.
|
ListContainer.Layout |
getLayout(int itemCount,
int itemsPerLine)
Creates a Layout object with the given parameters.
|
int |
getSelectedIndex()
Returns the selected index, or -1 if none is selected.
|
Container |
getSelectedItem()
Returns the selected container, or null if none is selected.
|
void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has
been added to a Container.
|
void |
onEvent(Event e)
Called to process key, pen, control and other posted events.
|
void |
removeAllContainers()
Removes all containers of this ListContainer.
|
void |
resize()
This method resizes the control to the needed bounds, based on added childs.
|
void |
scrollToControl(Control c)
Positions the given Container (that should be a control added to this ListContainer) at the top
of the list.
|
void |
setBackColor(Container c,
int back)
Changes the color of all controls inside the given container that matches the background color
of this ListContainer.
|
void |
setSelectedIndex(int idx)
Sets the selected container based on its index.
|
void |
setSelectedItem(Container c)
Sets the selected container.
|
int |
size()
Returns the number of items of this list
|
add, addScrollEventHandler, bagSetRect, canScrollContent, canShowScrollBars, disableFlick, enableFlick, flickEnded, flickStarted, getBagChildren, getBagInitialHeight, getBagInitialWidth, getClientRect, getFlick, getPreferredHeight, getPreferredWidth, getRealClientRect, getScrollDistance, getScrollPosition, moveFocusToNextControl, onBoundsChanged, onFontChanged, onPaint, remove, removeAll, removeScrollEventHandler, reposition, resize, scrollContent, scrollPage, scrollToOrigin, scrollToPage, setBorderStyle, setHandlersVisibility, setHandlersVisibility, setHValue, setScrollBars, setVValue, updateListenerTriggered, wasScrolled
add, add, add, add, broadcastEvent, clear, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, resizeHeight, resizeWidth, setBorderRadius, setEnabled, setFocusTraversable, setHighlighting, setInsets, setPressColor, setPressed, swapToTopmostWindow
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
protected Container lastSel
protected int lastSelBack
protected int lastSelIndex
public int highlightColor
public boolean drawHLine
public ListContainer.Layout getLayout(int itemCount, int itemsPerLine)
public void onColorsChanged(boolean colorsChanged)
Control
onColorsChanged
in class ScrollContainer
public int size()
public void addContainer(Container c)
addContainers(totalcross.ui.Container[])
public void addContainers(Container[] all)
Flick.defaultLongestFlick
public void removeAllContainers()
public void onEvent(Event e)
Control
onEvent
in class ScrollContainer
e
- the event to processEvent
,
KeyEvent
,
PenEvent
public Container getSelectedItem()
public int getSelectedIndex()
public void setSelectedIndex(int idx)
idx
- The index or -1 to unselect all containers.public void setSelectedItem(Container c)
public Container getContainer(int idx)
public void setBackColor(Container c, int back)
public void resize()
ScrollContainer
resize
in class ScrollContainer
Container.resizeWidth()
,
Container.resizeHeight()
public void scrollToControl(Control c)
scrollToControl
in class ScrollContainer