libgdx API

com.badlogic.gdx.scenes.scene2d.ui
Class List

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.ui.Widget
          extended by com.badlogic.gdx.scenes.scene2d.ui.List
All Implemented Interfaces:
Cullable, Layout

public class List
extends Widget
implements Cullable

A list (aka list box) displays textual items and highlights the currently selected item.

ChangeListener.ChangeEvent is fired when the list selection changes.

The preferred size of the list is determined by the text bounds of the items and the size of the List.ListStyle.selection.

Author:
mzechner

Nested Class Summary
static class List.ListStyle
          The style for a list, see List.
 
Constructor Summary
List(java.lang.Object[] items, List.ListStyle style)
           
List(java.lang.Object[] items, Skin skin)
           
List(java.lang.Object[] items, Skin skin, java.lang.String styleName)
           
 
Method Summary
 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()
           
 float getPrefHeight()
           
 float getPrefWidth()
           
 int getSelectedIndex()
           
 java.lang.String getSelection()
           
 List.ListStyle getStyle()
          Returns the list's style.
 void setCullingArea(Rectangle cullingArea)
           
 void setItems(java.lang.Object[] objects)
           
 void setSelectedIndex(int index)
           
 int setSelection(java.lang.String item)
           
 void setStyle(List.ListStyle style)
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, addAction, addCaptureListener, addListener, clearActions, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

List

public List(java.lang.Object[] items,
            Skin skin)

List

public List(java.lang.Object[] items,
            Skin skin,
            java.lang.String styleName)

List

public List(java.lang.Object[] items,
            List.ListStyle style)
Method Detail

setStyle

public void setStyle(List.ListStyle style)

getStyle

public List.ListStyle getStyle()
Returns the list's style. Modifying the returned style may not have an effect until setStyle(ListStyle) is called.


draw

public void draw(SpriteBatch batch,
                 float parentAlpha)
Description copied from class: Widget
If this method is overridden, the super method or Widget.validate() should be called to ensure the widget is laid out.

Overrides:
draw in class Widget
parentAlpha - Should be multipied with the actor's alpha, allowing a parent's alpha to affect all children.

getSelectedIndex

public int getSelectedIndex()
Returns:
The index of the currently selected item. The top item has an index of 0.

setSelectedIndex

public void setSelectedIndex(int index)

getSelection

public java.lang.String getSelection()
Returns:
The text of the currently selected item or null if the list is empty.

setSelection

public int setSelection(java.lang.String item)
Returns:
The index of the item that was selected, or -1.

setItems

public void setItems(java.lang.Object[] objects)

getItems

public java.lang.String[] getItems()

getPrefWidth

public float getPrefWidth()
Specified by:
getPrefWidth in interface Layout
Overrides:
getPrefWidth in class Widget

getPrefHeight

public float getPrefHeight()
Specified by:
getPrefHeight in interface Layout
Overrides:
getPrefHeight in class Widget

setCullingArea

public void setCullingArea(Rectangle cullingArea)
Specified by:
setCullingArea in interface Cullable
Parameters:
cullingArea - The culling area in the child actor's coordinates.

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)