|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.List
public class List
A list of string entries.
List.SelectionListener
can be
registered with the list to listen to selection changes. Entries have an index in the list, the top entry having the index 0.
Widget.setPrefSize(int, int)
to programmatically change the size to your liking. In case the width and height you set are to
small for the contained text you will see artifacts. The patch highlighting the current selection will have the width of the
List, either determined as explained above or set programmatically.
Widget
a text rendered for each list entry via a BitmapFont
and Color
as
well as a NinePatch
highlighting the current selection and a second Color used for the text of the currently selected
entry. The highlighting NinePatch is rendered beneath the selected entry. The style is defined via an instance of
List.ListStyle
, which can be done either programmatically or via a Skin
.
A List's style definition in an XML skin file should look like this:
<list name="styleName"
font="fontName"
fontColorUnselected="colorName"
fontColorSelected="colorName"
selected="selectedPatch"/>
name
attribute defines the name of the style which you can later use with
Skin#newList(String, String[], String)
.fontName
attribute references a BitmapFont
by name, to be used for render the entriesfontColorUnselected
attribute references a Color
by name, to be used for render unselected entries
fontColorSelected
attribute references a Color
by name, to be used to render the selected entryselected
attribute references a NinePatch
by name, to be used to render the highlight behind the
selected entry
Nested Class Summary | |
---|---|
static class |
List.ListStyle
Defines a list style, see List |
static interface |
List.SelectionListener
Interface for listening to selection changes. |
Field Summary |
---|
Fields inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
prefHeight, prefWidth |
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, touchable, visible, width, x, y |
Constructor Summary | |
---|---|
List(java.lang.String[] entries,
List.ListStyle style)
|
|
List(java.lang.String[] entries,
Skin skin)
|
|
List(java.lang.String name,
java.lang.String[] entries,
List.ListStyle style)
Creates a new List. |
Method Summary | |
---|---|
void |
draw(SpriteBatch batch,
float parentAlpha)
Draws the Actor. |
java.lang.String[] |
getEntries()
|
int |
getSelectedIndex()
|
java.lang.String |
getSelection()
|
Actor |
hit(float x,
float y)
|
void |
layout()
Positions and sizes each child of this actor. |
void |
setEntries(java.lang.String[] entries)
Sets the entries of this list. |
void |
setSelectedIndex(int index)
|
void |
setSelection(int index)
|
int |
setSelection(java.lang.String entry)
|
void |
setSelectionListener(List.SelectionListener listener)
Sets the List.SelectionListener of this list. |
void |
setStyle(List.ListStyle style)
Sets the style of this widget. |
boolean |
touchDown(float x,
float y,
int pointer)
|
void |
touchDragged(float x,
float y,
int pointer)
|
void |
touchUp(float x,
float y,
int pointer)
|
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
getPrefHeight, getPrefWidth, invalidate, invalidateHierarchy, setPrefSize |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
act, action, clearActions, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchMoved |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public List(java.lang.String[] entries, Skin skin)
public List(java.lang.String[] entries, List.ListStyle style)
public List(java.lang.String name, java.lang.String[] entries, List.ListStyle style)
name
- the nameentries
- the entriesstyle
- the List.ListStyle
Method Detail |
---|
public void setStyle(List.ListStyle style)
Widget.invalidateHierarchy()
internally.
style
- public void layout()
Layout
Layout.invalidate()
is
called.
public void draw(SpriteBatch batch, float parentAlpha)
Actor
FadeIn
and
other Actions to have an effect even if they are only set on the parent of the Actor.
draw
in class Actor
batch
- the spritebatch to render withparentAlpha
- the parent's alpha value.public boolean touchDown(float x, float y, int pointer)
touchDown
in class Actor
public void touchUp(float x, float y, int pointer)
touchUp
in class Actor
public void touchDragged(float x, float y, int pointer)
touchDragged
in class Actor
public Actor hit(float x, float y)
hit
in class Widget
public int getSelectedIndex()
public void setSelectedIndex(int index)
public java.lang.String getSelection()
public void setSelection(int index)
index
- sets the selected itempublic int setSelection(java.lang.String entry)
public void setEntries(java.lang.String[] entries)
entries
- the entries.public java.lang.String[] getEntries()
public void setSelectionListener(List.SelectionListener listener)
List.SelectionListener
of this list.
listener
- the listener or null
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |