Create Lists objects using the CreateList function of the app object:
lst = app.CreateList( list, width, height, options );
Use the SetOnTouch and SetOnLongTouch functions of the List to set the name of a function you want to be called when
a list item is selected. The selected item is passed into your OnTouch callback function as a parameter every time an item is
selected or long touched.
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( item ) {
app.ShowPopup( "Item = " + item, "Short" );
}
function lst_OnLongTouch( item ) {
app.ShowPopup( "Long Touch = " + item, "Short" );
}
You can change the look of a List using the SetBackColor and SetTextColor functions on the list object. You can also set a
background image/pattern or background gradient for the List using the SetBackground and SetBackGradient functions.
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( item ) {
app.ShowPopup( "Touched Item = " + item );
}