public class MultiListBox extends ListBox
MultiListBox mlb; new ComboBox(mlb = new MultiListBox())Be sure to save a reference to the MultiListBox so you can call the specific methods of this class. For instance, getSelectedIndex returns just the last selected index; to retrieve all indexes, use getSelectedIndexes.
ListBox.CustomDrawingItem, ListBox.IconItem
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
boolean |
changed
Internal use only.
|
IntVector |
clearValues
Fill this IntVector with the values that will be selected when the clear method is called.
|
static java.lang.String |
itemsText
Global suffix used to display the number of items in a ComboBox.
|
java.lang.String |
localItemsText
Local suffix to display the number of items in a ComboBox.
|
protected int |
maxSelections |
protected static int |
NO_OLD_SELECTION |
protected int |
oldSelection |
protected IntVector |
order |
protected IntHashtable |
selectedIndexes |
boolean |
showOrderInTip
Set to false to don't show the number of selected elements as they are clicked.
|
int |
tipDelay
The amount of time used to show how many itens.
|
boolean |
unselectFirstWhenMaxIsReached
Set to true if you want to unselect the first element once max is reached.
|
autoResizeIcon, back0, back1, btnX, btnX0, customCursorColor, dataCol, DEFAULT_ITEM_HEIGHT_FACTOR, drawBorder, EXTRA_HEIGHT_FACTOR, extraHorizScrollButtonHeight, flick, iconGap, iconSize, ihFactor, ihtBackColors, ihtForeColors, itemCount, itemHeightFactor, items, offset, paddingBottom, paddingLeft, paddingRight, paddingTop, sbar, selectedIndex, simpleBorder, tempSelectedIndex, useFullWidthOnSelection, visibleItems, visibleLines, xOffset
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, lastH, 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 |
---|
MultiListBox()
Constructs an empty MultiListBox.
|
MultiListBox(java.lang.Object[] items)
Constructs a MultiListBox with the given items.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cbddOnPopup()
Called by ComboBoxDropDown when its being popped.
|
protected void |
cbddOnUnpop()
Called by ComboBoxDropDown when its being unpopped.
|
void |
clear()
Clears this control, selecting index clearValueInt.
|
protected void |
drawItems(Graphics g,
int dx,
int dy,
int greatestVisibleItemIndex) |
protected void |
drawSelectedItem(Graphics g,
int from,
int to)
Draw all selected indexes
|
protected void |
endSelection() |
protected int |
getCursorColor(int index) |
java.lang.Object |
getLastSelectedItem()
Returns the last selected item if you had set order is important, otherwise returns null.
|
int |
getSelectedIndex()
Returns the selected index.
|
IntVector |
getSelectedIndexes()
Return a vector with the indexes which have been selected.
|
java.lang.String |
getText()
Returns the String with the selected item (if single) or a string with the number of selected items.
|
protected void |
handleClick(int index) |
Control |
handleGeographicalFocusChangeKeys(KeyEvent ke)
Used by the main event loop to give the currently focused control an opportunity to act directly on
the KeyEvent.
|
protected void |
handleSelection(int newSelection) |
boolean |
isOrderImportant()
Returns true if you requested that the order is important.
|
boolean |
isSelected(int index)
Returns if given index is selected.
|
protected void |
leftReached() |
protected 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)
Handles the events for this control.
|
void |
postPressedEvent()
Posts a ControlEvent.PRESSED event with this control as target.
|
void |
removeAll()
Empties this ListBox, setting all elements of the array to
null
so they can be garbage collected. |
void |
setMaxSelections(int max)
Defines the maximum number of items that can be selected.
|
void |
setOrderIsImportant(boolean set)
Call this method if you want to keep track of the order in which the items were selected.
|
void |
setSelectedIndex(int index)
In this MultiListBox, inverts the status of the given index, or clears all if i is -1.
|
void |
setSelectedIndex(int index,
boolean set)
Sets or clear an index.
|
add, add, add, add, addWrapping, canScrollContent, drawCursor, drawItem, drawSelectedItem, enableHorizontalScroll, find, flickEnded, flickStarted, getEffectH, getEffectW, getEffectX, getEffectY, getFlick, getFocusableControls, getItemAt, getItemHeight, getItems, getItemsArray, getItemWidth, getPreferredHeight, getPreferredWidth, getScrollPosition, getSelectedItem, hasIconItemLeft, hasIconItemRight, hideScrollBarIfNotNeeded, indexOf, insert, onBoundsChanged, onPaint, qsort, qsort, remove, remove, remove, scrollContent, selectLast, selectLast, setCursorColor, setEnabled, setItemAt, setSelectedItem, setSelectedItemStartingWith, setSimpleBorder, setTextAreaClip, size, wasScrolled
add, add, add, add, broadcastEvent, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, resize, resizeHeight, resizeWidth, setBorderRadius, setBorderStyle, 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, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onFontChanged, onWindowPaintFinished, post, postEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, 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 static final int NO_OLD_SELECTION
protected int maxSelections
protected int oldSelection
protected IntHashtable selectedIndexes
protected IntVector order
public boolean changed
public IntVector clearValues
public boolean showOrderInTip
public boolean unselectFirstWhenMaxIsReached
public static java.lang.String itemsText
public java.lang.String localItemsText
public int tipDelay
public MultiListBox()
public MultiListBox(java.lang.Object[] items)
public void setOrderIsImportant(boolean set)
public boolean isOrderImportant()
public int getSelectedIndex()
getSelectedIndex
in class ListBox
public java.lang.Object getLastSelectedItem()
public void setMaxSelections(int max)
public IntVector getSelectedIndexes()
qsort
.public boolean isSelected(int index)
public void removeAll()
ListBox
null
so they can be garbage collected. Attention! If you used the same
object array to initialize two ListBoxes (or ComboBoxes), this method will
null both ListBoxes (because they use the same array reference), and you'll
get a null pointer exception!protected void onColorsChanged(boolean colorsChanged)
Control
onColorsChanged
in class ListBox
protected void drawSelectedItem(Graphics g, int from, int to)
drawSelectedItem
in class ListBox
protected void drawItems(Graphics g, int dx, int dy, int greatestVisibleItemIndex)
protected int getCursorColor(int index)
getCursorColor
in class ListBox
public void setSelectedIndex(int index)
setSelectedIndex
in class ListBox
setSelectedIndex(int, boolean)
protected void leftReached()
leftReached
in class ListBox
public void setSelectedIndex(int index, boolean set)
setSelectedIndex
in class ListBox
protected void handleSelection(int newSelection)
handleSelection
in class ListBox
protected void cbddOnPopup()
protected void cbddOnUnpop()
public void postPressedEvent()
Control
postPressedEvent
in class Control
protected void endSelection()
endSelection
in class ListBox
protected void handleClick(int index)
public java.lang.String getText()
public void onEvent(Event e)
ListBox
public Control handleGeographicalFocusChangeKeys(KeyEvent ke)
Control
handleGeographicalFocusChangeKeys
in class ListBox
ke
- The KeyEvent to be processedSettings.geographicalFocus