Back

CreateListDialog

Hello World
Content:
- Methods

If you want a quick way to let the user select one or even multiple items of a given dataset you can use the ListDialog.

ldg = app.CreateListDialog( title, list, options ) → app object: ListDialog

Use the SetOnTouch method of the ListDialog object to set the name of a function you want to be called every times a list item is selected. The selected item is passed that function as parameter.

Example - Basic

function OnStart()
{
    dlg = app.CreateListDialog( "Choices", "Add,Remove,Delete" );
    dlg.SetOnTouch( dlg_OnTouch );
    dlg.Show();

}

function dlg_OnTouch( item )
{
    app.ShowPopup( item );
}
    Copy     Copy All       Run      

ou can use the “Multi” option to create a ListDialog with check boxes against each item. This allows multiple list items to be selected. An extra parameter isChecked is passed to the OnTouch callback function when a check box is checked or unchecked.

Example - Multi

function OnStart()
{
    dlg = app.CreateListDialog( "Days", "Mon,Tues,Wed,Thurs,Fri,Sat,Sun", "Multi" );
    dlg.SetOnTouch( dlg_OnTouch );
    dlg.Show();

}

function dlg_OnTouch( item, isChecked )
{
    app.ShowPopup( item + " isChecked = " + isChecked );
}
    Copy     Copy All       Run      

Methods

The following methods are available on the ListDialog object:

GetType() → string: “ListDialog”
Hide()
Method( name, types, p1, p2, p3, p4 ) → all types
Show()
number
string
number: -180..180
number: -100..100
number: 0..100
string:
  hexadecimal: “#rrggbb”, “#aarrggbb”
  colourName: “red”, “green”, ...
string: path to file or folder ( “/absolute/...” or “relative/...” )
string: comma “,” separated: “Multi” or “?”
string: “repeat”
string: “px” or “sp” or “dip” or “dp” or “mm” or “pt”
list: boolean,char,byte,short,int,long,float,double,String,CharSequence,...
function( title, checked )
ldg.AdjustColor
Adjust the visual color effect of the control by setting the Hue (by angle in degrees in a color circle), the saturation, brightness and contrast of the control.
ldg.Dismiss
Hide the control and remove it from the screen.
ldg.GetType
Returns the control class name.
ldg.Hide
Hide the control but keep the layout space free.
ldg.Method
Allows access to other functions defined on the object in Java via reflection.

Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.
ldg.SetBackColor
Changes the background color of the control.
ldg.SetBackground
Changes the background to an image which can be repeated using the repeat option.
An image which is often used with that option is '/res/drawable/pattern_carbon' - try it out!
ldg.SetOnTouch
Define a callback function that is called when the user touches a list item.
ldg.SetSize
Change the size of the control in either screen relative values or in pixels if the px option was given.
ldg.SetTextColor
Change the text color of the contained text.
ldg.SetTitle
Change the dialog title.
ldg.Show
Set the visibility of the control to “Show”.