Back

CreateList

CreateList creates a List object.

app.CreateList( list, width, height, options ) -> app object - List

Example - Simple



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    lst = app.CreateList( "Fred,Bill,Jim", 0.8, 0.4 );
    lst.SetOnTouch( lst_OnTouch );
    lst.SetOnLongTouch( lst_OnLongTouch );
    lay.AddChild( lst );

    app.AddLayout( lay );
}

function lst_OnTouch( title, body, type, index )
{
    app.ShowPopup( "Item = " + title + ", Index = " + index, "Short" );
}
function lst_OnLongTouch( )
{
    app.ShowPopup( "Long Touch Item = " + title + ", Index = " + index, "Short" );
}
    Copy     Copy All       Run      

Example - Gray on White



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    lst = app.CreateList( "Fred,Bill,Jim", 0.8, 0.4 );
    lst.SetTextColor( "#ff666666" );
    lst.SetBackColor( "#ffffffff" );
    lst.SetOnTouch( lst_OnTouch );
    lay.AddChild( lst );

    app.AddLayout( lay );
}

function lst_OnTouch( title, body, type, index )
{
    app.ShowPopup( "Touched Item = " + title );
}
    Copy     Copy All       Run      

Example - Title + Icon



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    var data = "Folder:folder,Audio:audio,Photo:photo,Video:video";
    lst = app.CreateList( data, 0.8, 0.4 );
    lst.SetOnTouch( lst_OnTouch );
    lay.AddChild( lst );

    app.AddLayout( lay );
}

function lst_OnTouch( title, body, type, index )
{
    app.ShowPopup( "Touched Item = " + title );
}
    Copy     Copy All       Run      

Example - Title + Body



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    var data = "The Hobbit:Author^c^ J.R.R. Tolkien:null";
    data += ",Watership Down:Author^c^ Richard Adams:null";
    lst = app.CreateList( data, 0.8, 0.4 );
    lst.SetOnTouch( lst_OnTouch );
    lay.AddChild( lst );

    app.AddLayout( lay );
}

function lst_OnTouch( title, body, type, index )
{
    app.ShowPopup( "Touched Item = " + title );
}
    Copy     Copy All       Run      

Example - Orange Buttons



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    var data = "Button 1,Button 2,Button 3,Button 4";
    lst = app.CreateList( data, 0.8, 0.8, "OrangeButton" );
    lst.SetBackColor( "#ffffff" );
    lst.SetPadding( 0.1, 0.1, 0.1, 0.1 );
    lst.SetOnTouch( lst_OnTouch );
    lay.AddChild( lst );

    app.AddLayout( lay );
}

function lst_OnTouch( title, body, type, index )
{
    app.ShowPopup( "Touched Item = " + title );
}
    Copy     Copy All       Run      

Example - Gradient Background



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    var data = "";
    for( var i=1; i<=30; i++)
    {
        if( i>1 ) data += ",";
        data += "Item "+i+":Details for item "+i+":null";
    }
    lst = app.CreateList( data, 1, 1, "WhiteGrad" );
    lst.SetTextColor1( "#ff555558");
    lst.SetTextColor2( "#ff555558" );
    lst.SetTextMargins( 0.04, 0, 0, 0 );
    lst.SetOnTouch( lst_OnTouch );
    lay.AddChild( lst );

    app.AddLayout( lay );
}

function lst_OnTouch( title, body, type, index )
{
    app.ShowPopup( "Touched Item = " + title );
}
    Copy     Copy All       Run      

The following methods are avaiable on the List object:

  Destroy()
  Explode()
  Focus()
  GetAbsHeight() -> number - integer
  GetAbsWidth() -> number - integer
  GetHeight( options ) -> number - fraction of screen height
  GetItem( title ) -> unknown
  GetItemByIndex( index ) -> unknown
  GetLeft( options ) -> number - fraction of screen width
  GetLength() -> number - integer
  GetList( delim ) -> unknown
  GetPosition( options ) -> object - { left: fraction of parent width, top: fraction of parent height, right: fraction of parent width, bottom: fraction of parent height }
  GetTextSize( mode ) -> number
  GetTop( options ) -> number - fraction of screen height
  GetType() -> string - "List"
  GetVisibility() -> string - "Show" or "Hide" or "Gone"
  GetWidth( options ) -> number - fraction of screen width
  Gone()
  Hide()
  IsEnabled() -> boolean
  IsOverlap( obj, depth ) -> boolean
  IsVisible() -> boolean
  Release()
  RemoveAll()
  SetScale( x, y )
  Show()
  id -> string - "#id"

string
number - fraction of screen width
number - fraction of screen height
string - "WhiteGrad" or "AlumButton" or "GreenButton" or "OrangeButton" or "html" or "FontAwesome"
string - path to file or folder ( "/absolute/..." or "relative/..." )
number
set color effects
?
destroys object
destroys object with explode animation and sound
?
get height in pixels
get width in pixels
unknown
get screen relative height
get item data by title
number - integer
GetItemByIndex
get distance to left parent border
GetLength
get full list data
GetTextSize
get distance to upper parent border
GetVisibility
get screen relative width
Set visibility "Gone"
Set visibility "Hide"
InsertItem
IsEnabled
app object
return wether obj overlap with an other
IsVisible
?
RemoveAll
RemoveItem
RemoveItemByIndex
ScrollToItem
ScrollToItemByIndex
boolean
SelectItem
SelectItemByIndex
string -
  hexadecimal: "#rrggbb", "#aarrggbb"
  colourName: "red", "green", ...
SetBackColor
SetBackColorRadial
changes the background image
string - "Add" or "Multiply" or "?"
adjust color
?
number - pixel
?
?
?
en/disable object
change font style
?
?
icon borders
SetIconSize
SetItem
SetItemByIndex
string - comma separated
SetList
move object from current position
function( self )
callen when object long pressed
function()
called when user touches object
set surrounding borders
SetPosition
number - factor
SetScale
change object size
change text str_col
?
?
change position from current
SetTextShadow
number - angle in degrees ( 0 - 360 )
?
?
SetTextSize
?
?
string - "Show" or "Hide" or "Gone"
change visibility mode
Set visibility "Show"
?
object id