public class SelectBox extends Widget implements Disableable
ChangeListener.ChangeEvent
is fired when the selectbox selection changes.
The preferred size of the select box is determined by the maximum text bounds of the items and the size of the
SelectBox.SelectBoxStyle.background
.
Modifier and Type | Class and Description |
---|---|
static class |
SelectBox.SelectBoxStyle
The style for a select box, see
SelectBox . |
Constructor and Description |
---|
SelectBox(java.lang.Object[] items,
SelectBox.SelectBoxStyle style) |
SelectBox(java.lang.Object[] items,
Skin skin) |
SelectBox(java.lang.Object[] items,
Skin skin,
java.lang.String styleName) |
Modifier and Type | Method and Description |
---|---|
void |
draw(SpriteBatch batch,
float parentAlpha)
If this method is overridden, the super method or
Widget.validate() should be called to ensure the widget is laid out. |
java.lang.String[] |
getItems() |
int |
getMaxListCount() |
float |
getPrefHeight() |
float |
getPrefWidth() |
java.lang.String |
getSelection() |
int |
getSelectionIndex() |
SelectBox.SelectBoxStyle |
getStyle()
Returns the select box's style.
|
void |
hideList() |
void |
setDisabled(boolean disabled) |
void |
setItems(java.lang.Object[] objects) |
void |
setMaxListCount(int maxListCount)
Set the max number of items to display when the select box is opened.
|
void |
setSelection(int selection)
Sets the selected item via it's index
|
void |
setSelection(java.lang.String item) |
void |
setStyle(SelectBox.SelectBoxStyle style) |
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
act, addAction, addCaptureListener, addListener, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, hit, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setParent, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translate
public SelectBox(java.lang.Object[] items, Skin skin)
public SelectBox(java.lang.Object[] items, Skin skin, java.lang.String styleName)
public SelectBox(java.lang.Object[] items, SelectBox.SelectBoxStyle style)
public void setMaxListCount(int maxListCount)
public int getMaxListCount()
public void setStyle(SelectBox.SelectBoxStyle style)
public SelectBox.SelectBoxStyle getStyle()
setStyle(SelectBoxStyle)
is called.public void setItems(java.lang.Object[] objects)
public java.lang.String[] getItems()
public void draw(SpriteBatch batch, float parentAlpha)
Widget
Widget.validate()
should be called to ensure the widget is laid out.public void setSelection(int selection)
selection
- the selection indexpublic void setSelection(java.lang.String item)
public int getSelectionIndex()
public java.lang.String getSelection()
public void setDisabled(boolean disabled)
setDisabled
in interface Disableable
public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
public void hideList()