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.

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

Author:
mzechner

Nested Class Summary
static class List.ListStyle
          The style for a list, see List.
 
Field Summary
 
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, stage, touchable, visible, width, x, y
 
Constructor Summary
List(java.lang.Object[] items, List.ListStyle style)
           
List(java.lang.Object[] items, List.ListStyle style, java.lang.String name)
           
List(java.lang.Object[] items, Skin skin)
           
List(Skin skin)
           
 
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 setSelectionListener(SelectionListener listener)
           
 void setStyle(List.ListStyle style)
           
 boolean touchDown(float x, float y, int pointer)
           
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, hit, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, toScreenCoordinates, touchDragged, touchUp, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, action, clearActions, getStage, 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

List

public List(Skin skin)

List

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

List

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

List

public List(java.lang.Object[] items,
            List.ListStyle style,
            java.lang.String name)
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
Parameters:
batch - the spritebatch to render with
parentAlpha - the parent's alpha value.

touchDown

public boolean touchDown(float x,
                         float y,
                         int pointer)
Overrides:
touchDown in class Widget

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

setSelectionListener

public void setSelectionListener(SelectionListener listener)
Parameters:
listener - May be null.

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)