BasicIDE B4Script Language Extensions
Script Events
General Functions
String Functions
Device Functions
Activity Functions
Array Functions
File Functions
Add View Functions
Shared View Functions
Check, Radio and Toggle Functions
EditText Functions
Graphics Functions
ListView Functions
ListView and Spinner Functions
ProgressBar Functions
ScrollView Functions
SeekBar Functions
Spinner Functions
TabHost Functions
Textview Functions
Timer Functions
User Interaction Functions
Color Constants
KeyCode Functions and Constants
Gravity Constants
Typeface Constants
Contents
SCRIPT EVENTS
If a Sub of any of these names are defined in the program then it will be called at the appropriate time.
The 'who' parameter will be set to the name of view that caused the event.
Use Template.b4s as a starting point for a project and enter the event code as needed.
Activity_Create
There is no supported Activity_Create sub.
Instead the inital block of code block from the beginning of the script up to the first Sub statement is run.
GetFirstTime returns True the first time the initial code block is run after a program is started.
This block of code will be run again whenever the Activity is re-created
Activity_Pause(userclosed)
"Sub activity_pause(userclosed)" is called if implemented. userclosed will be True if the [Back] button was pressed.
Activity_Resume
"Sub activity_resume" is called if implemented.
Activity_Keypress(keycode)
"Sub activity_keypress(keycode)" is called if implemented.
Keycode will contain the system key code of the key pressed, and may be tested using the KEYCODE FUNCTIONS and KEYCODE CONSTANTS.
Return True from Activity_Keypress(keycode) to consume the keystroke (ie. not allow the system to continue processing it.)
Example:
Sub Activity_Keypress(keycode)
# process numbers only, all others ignored
If keycode = Key_isNumber(keycode)
# process the keystroke here...
# then consume the keystroke
Return true
End If
End Sub
Button_Click(who)
All Button Click events are vectored to a single BasicLib sub "Sub button_click(who)".
Check_CheckedChange(who, checked)
All Checkbox CheckedChange events are vectored to a single BasicLib sub "Sub check_checkedchange(who, checked)".
Edit_EnterPressed(who)
All EditText EnterPressed events are vectored to a single BasicLib sub "Sub edit_enterpressed(who)".
Edit_TextChanged(who, oldtext, newtext)
All EditText TextChanged events are vectored to a single BasicLib sub "Sub edit_textchanged(who, oldtext, newtext)".
Edit_FocusChanged(who, hasfocus)
All Edittext FocusChanged events are vectored to a single BasicLib sub "Sub edit_focuschanged(who, hasfocus)".
HSV_Changed(who, position)
All HorizontalScrollView ScrollChanged events are vectored to a single BasicLib sub "Sub hsv_scrollchanged(who, position)".
Label_Click(who)
All Label Click events are vectored to a single BasicLib sub "Sub label_click(who)".
Listview_ItemClick(who, position, value)
All ListView ItemClick events are vectored to a single BasicLib sub "Sub listview_itemclick(who, position, value)".
Menu_Click(menutext)
All menu item click events are vectored to a single BasicLib sub "Sub menu_click(menutext)".
Panel_Click(who)
All Panel Click events are vectored to a single BasicLib sub "Sub panel_click(who)".
Radio_CheckedChange(who, checked)
All RadioButton CheckedChange events are vectored to a single BasicLib sub "Sub radio_checkedchange(who, checked)".
Seekbar_ValueChanged(who, userchanged)
All SeekBar ValueChanged events are vectored to a single BasicLib sub "Sub seekbar_valuechanged(who, value, userchanged)".
Spinner_ItemClick(who, position, value)
All Spinner ItemClick events are vectored to a single BasicLib sub "Sub spinner_itemclick(who, position, value)".
Tabhost_TabChanged(who)
All TabHost TabChanged events are vectored to a single BasicLib sub "Sub tabhost_tabchanged(who)".
Timer_Tick
All Timer tick events are vectored to a single BasicLib sub "Sub timer_tick".
Toggle_Changed(who, checked)
All ToggleButton CheckedChange events are vectored to a single BasicLib sub "Sub toggle_changed(who, checked)".
Event Templates
Here are all the event Sub templates to copy and paste if desired.
Sub activity_pause(userclosed)
End Sub
Sub activity_resume
End Sub
End Sub
Sub button_click(who)
End Sub
Sub check_checkedchange(who, checked)
End Sub
Sub edit_enterpressed(who)
End Sub
Sub edit_textchanged(who, old, new)
End Sub
Sub edit_focuschanged(who, hasfocus)
End Sub
Sub hsv_scrollchanged(who, position)
End Sub
Sub label_click(who)
End Sub
Sub listview_itemclick(who, pos, value)
End Sub
Sub menu_click(menutext)
End Sub
Sub panel_click(who)
End Sub
Sub radio_checkedchange(who, checked)
End Sub
Sub seekbar_valuechanged(who, pos, value)
End Sub
Sub spinner_itemclick(who, pos, value)
End Sub
Sub tabhost_tabchanged(who)
End Sub
Sub timer_tick
End Sub
Sub toggle_changed(who, checked)
End Sub
Contents
GENERAL SYSTEM FUNCTIONS
CloseApplication
On Android 4+ will close all the activities.
When called in a script this will exit the application without resuming the IDE activity.
AppClose in contrast will just close this activity and return to the Main activity.
IIf(condition, truepart, falsepart)
IIf is a function that performs an If...Else...End If as a one line statement.
IIf has 3 parts: a condition, a True part and a False part.
The condition is evaluated, and if it evaluates true, the true part is returned, otherwise the false part is returned.
It should not replace an If block that makes tests to ensure an error will not result.
This is because as both True part and False part are evaluated when the function is called.
Example:
# instead of this...
If a = 5 Then
b = b + 1
Else
b = b - 1
Endif
# use this...
b = b + IIf(a = 5, 1, -1)
HideKeyboard
Hides the soft keyboard.
Contents
STRING FUNCTIONS
SBAppend(text)
Append 'text' to the end of the String Builder object.
SBInitialize
There is a single String Builder object which can be used as many times as needed.
Initialize (or reinitialize) the String Builder object.
If the String Builder object is already initialized, it will be reinitialized and its text reset to blank.
SBInsert(offset, text)
Insert 'text' at the offset specified, in the String Builder object.
SBLength
Returns the length of the text in the String Builder object.
SBRemove(start, end)
Remove the text starting at 'start' offset up to, but not including, the 'end' offset, of the String Builder object.
SBToString
Returns the text in the String Builder object.
StrTrim(string)
Returns a string that has had white space trimmed from the start and end of the passed string
Ex. StrTrim(" 123 ") returns "123"
Contents
DEVICE FUNCTIONS
ActivityHeight
Get the available height of the activity.
Depending upon the device orientation this is not necessarily the same as the physical display height.
ActivityWidth
Get the available width of the activity.
Depending upon the device orientation this is not necessarily the same as the physical display width.
GetLayoutValues
Get the layout values for this device in a comma separated string "width,height,density".
GetOrientation
Returns the orientation of the device as either 'Portrait' or 'Landscape'.
ScreenScale
Get the scaling value (density) for this device.
Contents
ACTIVITY FUNCTIONS
ActivityFinish
Closes the Activity and return directly to the editor. this may sometimes be required.
Calling this bypasses the normal Blib_Ended code that will display any Print output and any error message
Close a script without events by calling CloseAfterThis and close a script with events by AppClose.
SetActivityTitle(title)
Sets the activity title text in the activity's title label
CloseMenu
Closes the Activity menu. This is added for symmetry with OpenMenu but seems of little practical use.
GetFirstTime
Returns true if this is the first time the initial code block program has been run.
This is the equivalent of FirstTime in Activity_Create except this is for the program, not the activity.
CloseAfterThis
Call somewhere before the end of the initial code block for a program that does not support events.
Otherwise the program will be left waiting for an event that won't come and the back button will be needed to close it.
A program that does use events can end by calling AppClose.
LogCat(message)
Logs the provided message to the Logcat output.
OpenMenu
Opens the Activity menu
SetActivityBackground(orientation, radius, colorsarrayname)
Set the Background property of the Activity to the GradientDrawable.
Returns false if less than two colors are in the array otherwise returns true.
Orientation can be one of the following:
"TOP_BOTTOM", "TR_BL" (Top-Right To Bottom-Left), "RIGHT_LEFT", "BR_TL" (Bottom-Right To Top-Left)
"BOTTOM_TOP", "BL_TR" (Bottom-Left To Top-Right), "LEFT_RIGHT", "TL_BR" (Top-Left To Bottom-Right)
Contents
ARRAY FUNCTIONS
FillArray(arrayname, start, length, value)
Fully or partially fills the specified array with the specified value.
SortArray(arrayname, sorttype)
Sort the specified array into ascending order in the specified manner.
One of cCaseSensitive (0), cCaseUnensitive (1) or cNumbers (2).
cCaseInsensitive is also accepted as a synonym for cCaseUnensitive'
Note that for use with BinarySearch cCaseSensitive should be used otherwise the result may not be accurate
SearchArray(arrayname, value)
Searches the specified array for the specified value using the binary search algorithm.
The array must be sorted into ascending order using cCaseSensitive otherwise the result may not be accurate..
Contents
FILE FUNCTIONS
FileCopy(sourcedir, sourcefilename, destdir, destfilename)
Copies the SourceFilename file in the SourceDir directory to the DestFilename directory and sets the name to DestFilename.
FileDelete(dir, filename)
Deletes the specified file. If the file name is a directory then it must be empty in order to be deleted.
Returns true if the file was successfully deleted.
Files in the assets folder cannot be deleted.
Returns true if successful, false otherwise.
FileDirAssets
Returns a reference to the files added with the Files Manager. These files are read-only.
This is actually the string "AssetsDir" which B4A OpenInput(Dir, String) treats specially as a Dir parameter
This is why FileGetPath does not support FileDirAssets as it then lacks the unique name that OpenInput looks for.
FileDirDefaultExternal
Returns the application default external folder which is based on the package name.
The folder is created if needed.
FileDirInternal
Returns the internal private storage dir.
FileDirRootExternal
Returns the root folder of the external storage media.
FileExists(dir, filename)
Returns true if the specified FileName exists in the specified Dir.
Note that the Android file system is case sensitive.
FileGetPath(dir, filename)
Returns the fully qualified pathname of the filename. This does not support the Assets directory.
FileIsDirectory(dir, filename)
Tests whether the specified file is a directory.
FileIsSDCard
Tests the external media, or SDCard (some devices call this Internal Storage), for readibility and writability.
FileListFiles(dir, filesarrayname)
Fills an array with a list with all the files and directories which are stored in the specified path.
Returns true if successful, false otherwise.
FileMakeDir(parentdir, dir)
Creates the given folder (dir can be a path like "dir1/dir2", creates all folders as needed).
Returns true if successful, false otherwise.
FileReadList(dir, filename, listarrayname)
Reads the entire file and fills a named array with all lines as strings.
Returns true if successful, false otherwise.
FileReadString(dir, filename)
Reads the entire file and returns it as a string.
Returns an empty string on failure.
FileRename(dir, oldfilename, newfilename)
Renames the old filename to the new filename.
Note that this method uses the B4A File.Copy and File.Delete methods internally.
FileWriteList(dir, filename, listarrayname)
Writes each item in the List As a single line.
Note that a value containing CRLF will be saved as two lines which will return two items when read with ReadList.
Returns true if successful, false otherwise.
FileWriteString(dir, filename, text)
Writes the given text to a new file.
Returns true if successful, false otherwise.
Contents
ADD VIEW FUNCTIONS
The Add view functions use four parameters; name, left, top, width, height, and parent.
Parent should be an empty string (ie. "") if adding to the activity.
If you add a view you need to add all the event subs for that type of view.
This because, for efficiency, the event Subs are assumed to be all there for an existing view.
Using Template.b4s as a starting point does this for you. Fill the event code in as needed.
AddButton(buttonname, left, top, width, height, parent)
Add a Button to the activity or a panel.
AddCheckBox(checkboxname, left, top, width, height, parent)
Add a CheckBox to the activity.
AddEditText(edittextname, left, top, width, height, parent)
Add an EditText to the activity or a panel.
AddHorizontalScroll(horizontalscrollname, left, top, width, height, parent)
Add a Horizontal Scroll view to the activity or panel
AddImage(imagename, left, top, width, height, parent)
Add an ImageView to the activity or a panel.
AddLabel(labelname, left, top, width, height, parent)
Add a Label to the activity or a panel.
AddListView(listviewname, left, top, width, height, parent)
Add a ListView to the activity or a panel.
AddMenuItem(menutext)
Add a MenuItem to the Activity.
AddPanel(panelname, left, top, width, height, parent)
Add a Panel to the activity or a panel.
AddProgressBar(panelname, left, top, width, height, parent)
Add a ProgressBar to the activity or a panel.
AddRadioButton(radiobuttonname, left, top, width, height, parent)
Add a RadioButton to the activity or a panel.
AddScrollView(scrollviewname, left, top, width, height, parent)
Add a ScrollView to the activity or a panel.
AddSeekBar(seekbarname, left, top, width, height, parent)
Add a SeekBar to the activity or a panel.
AddSpinner(spinnername, left, top, width, height, parent)
Add a Spinner to the activity or a panel.
AddTabHost(tabhostname, left, top, width, height, parent)
Add a TabHost to the activity or a panel.
AddToggleButton(togglebuttonname, left, top, width, height, parent)
Add a ToggleButton to the activity or a panel.
RemoveAllViews
Removes all views from the Activity
RemoveFromParent(viewname)
Removes the named view from its parent, but doesn't destroy it.
Used primarily for hiding a panel containing views to be used for popup help screens and custom input dialogs.
RemoveView(name)
Completely remove the named view from the program. It will no longer be available in the program.
SetNewParent(viewname, parent)
Removes the named view from its existing parent, if any, and adds it to the specified parent which must be an Activity or Panel
Contents
SHARED VIEW FUNCTIONS
These functions apply to all views.
BringToFront(viewname)
Bring the named view to the front of the Z order.
GetEnabled(viewname)
Get the Enabled property of the named view.
GetHeight(viewname)
Get the Height property of the named view.
GetLeft(viewname)
Get the Left property of the named view.
GetRight(viewname)
Gets the right side of the named view
GetTop(viewname)
Get the Top property of the named view.
GetVisible(viewname)
Get the Visible property of the named view.
GetWidth(viewname)
Get the Width property of the named view.
Invalidate(viewname)
Invalidate the named view.
Invalidate graphics updates to a view through Canvas drawing routines so a CallDoEvents will repaint the View.
See GRAPHICS FUNCTIONS for more info.
IsView(viewname)
Returns true if the named view exists, otherwise false.
RequestFocus(viewname)
Set the focus to the named view. Only views with editable text and a cursor may receive focus.
SendToBack(viewname)
Send the named view to the back of the Z order.
SetBackground(viewname, radius, color)
Set the Background property of the named view to a ColorDrawable.
SetBackgroundGradient(viewname, orientation, radius, colorsarrayname)
Set the Background property of the named view to a GradientDrawable.
Returns false if less than two colors are in the array or name not found otherwise returns true.
Orientation can be one of the following:
"TOP_BOTTOM", "TR_BL" (Top-Right To Bottom-Left), "RIGHT_LEFT", "BR_TL" (Bottom-Right To Top-Left)
"BOTTOM_TOP", "BL_TR" (Bottom-Left To Top-Right), "LEFT_RIGHT", "TL_BR" (Top-Left To Bottom-Right)
SetBackgroundImage(viewname)
Set the BackgroundImage of the view to the present bitmap. See GRAPHICS FUNCTIONS for more info.
Return true if both view and bitmap are initialised otherwise return false.
SetColor(viewname, radius, color)
Set the Background property of the named view to a ColorDrawable.
SetEnabled(viewname, enabled)
Set the true/false Enabled property of the named view.
SetHeight(viewname, height)
Set the Height property of the named view.
SetLeft(viewname, left)
Set the Left property of the named view.
SetTop(viewname, top)
Set the Top property of the named view.
SetVisible(viewname, visible)
Set the true/false Visible property of the named view.
SetWidth(viewname, width)
Set the Width property of the named view.
Contents
CHECKBOX, RADIOBUTTON AND TOGGLEBUTTON FUNCTIONS
CheckBox, RadioButton and ToggleButton support these functions in addition to the Shared View functions.
GetChecked(viewname)
Get the Checked state of a CheckBox, RadioButton or ToggleButton.
SetChecked(viewname, checkedstate)
Set the Checked state of a CheckBox, RadioButton or ToggleButton.
SetTextOff(togglebuttonname, text)
Sets the text that will appear in the OFF mode.
SetTextOn(togglebuttonname, text)
Sets the text that will appear in the ON mode.
Contents
EDITTEXT FUNCTIONS
EditText supports these functions in addition to the View and TextView functions.
GetSelectionStart(edittextname)
Gets the selection start position (or the cursor position) of the EditText.
Returns -1 if there is no selection or cursor.
SelectAll(edittextname)
Selects all text of the named edittext view.
SelectText(edittextname, selectionstart, selectionlength)
Selects text within the named edittext, starting at offset selectionstart and extending selectionlength characters.
SetForceDoneButton(edittextname, forcestate)
Force the EditText virtual keyboard action key to display Done by setting this value to True.
SetHint(edittextname, hinttext)
Set the text that will appear when the EditText is empty.
SetHintColor(edittextname, hintcolor)
Set the color of the text that will appear when the EditText is empty.
SetInputType(edittextname, inputtype)
Set the value of the EditText InputType property.
NONE = 0; TEXT = 1; NUMBERS = 2; _PHONE = 3; DECIMAL_NUMBERS = 12290;
SetPasswordMode(edittextname, state)
Set the true or false value of the EditText PasswordMode property.
SetSelectionStart(edittextname, startposition)
Sets the selection start position (or the cursor position) of the EditText.
SetSingleLine(edittextname, singlelinestate)
Set the true/false value of the EditText SingleLine property.
SetWrap(edittextname, wrapstate)
Set the true/false value of the EditText Wrap property.
Contents
GRAPHICS FUNCTIONS
There is a single bitmap object, which can be initialised from an image file or as a new mutable bitmap.
There is a single canvas object, which can be initialised on any view, or on a mutable bitmap.
Both the bitmap and canvas objects may be reinitialised as many times as needed.
Rectangles are assumed to be the names of a BasicLib array of rank 4 with coordinates of two points.
The array items are ordered as left(0), top(1) of the upper left point and, right(2) and bottom(3) of the lower right point.
Points are assumed to be consecutive items in an array ordered as xpos(2n+0) and ypos(2n+1).
The drawings will only be updated after a call to ParentView.Invalidate.
BitmapHeight
Get the height of the current bitmap.
BitmapInit(dir, filename)
(Re)initialise the bitmap to a graphic file.
BitmapInitMutable(width, height)
(Re)initialise the bitmap to a mutable bitmap.
BitmapWidth
Get the width of the current bitmap.
CanvasInit(viewname)
(Re)initialise the canvas object on any View.
CanvasInit2
The one canvas can also be reinitialised on a mutable Bitmap if the sole Bitmap object is one.
DrawBitmap(srcrectarrayname, destrectarrayname)
Draws the present bitmap
SrcRect - The rectangular area of the Bitmap that will be drawn.
DestRect - The rectangular area that the Bitmap will be drawn to.
Returns false if more or less than two points are in the rectangle arrays otherwise returns true.
DrawBitmapFlipped(srcrectarrayname, destrectarrayname, vertically, horizontally, )
Draws the present bitmap either horizontally, vertically or both..
SrcRect - The rectangular area of the Bitmap that will be drawn.
DestRect - The rectangular area that the Bitmap will be drawn to.
Returns false if more or less than two points are in the rectangle arrays otherwise returns true.
DrawBitmapRotated(srcrectarrayname, destrectarrayname, degrees)
Draws the present bitmap rotated.
SrcRect - The rectangular area of the Bitmap that will be drawn.
DestRect - The rectangular area that the Bitmap will be drawn to.
Returns false if more or less than two points are in the rectangle arrays otherwise returns true.
DrawCircle(x, y, radius, color, filled, strokewidth)
Draws a circle.
DrawColor(color)
Fills the entire canvas with the given color.
DrawLine(x1, y1, x2, y2, color, strokewidth)
Draws a line.
DrawOval(rectarrayname, radius, color, filled, strokewidth)
Draws an ellipse.
Returns false if more or less than two points are in the array otherwise returns true.
DrawRotatedOval(rectarrayname, radius, color, filled, strokewidth, degrees)
Draws a rotated ellipse.
Returns false if more or less than two points are in the array otherwise returns true.
DrawPath(pointsarrayname, color, filled, strokewidth)
Draws a set of connected lines from the points provided in a named array.
Returns false if less than two points are in the array otherwise returns true.
DrawPoint(x, y, color)
Sets a single pixel to the specified color.
DrawRect(rectarrayname, color, filled, strokewidth)
Draws a rectangle from the points provided in a named array.
Returns false if more or less than two points are in the array otherwise returns true.
DrawRectRotated(rectarrayname, color, filled, strokewidth, degrees)
Draws a rotated rectangle from the points provided in a named array and a specified angle.
Returns false if more or less than two points are in the array otherwise returns true.
DrawText(text, x, y, textsize, textcolor, align)
Draw text. Align is one of the following values: "LEFT", "CENTER", "RIGHT".
DrawTextRotated(text, x, y, textsize, textcolor, align, degrees)
Draw text. Align is one of the following values: "LEFT", "CENTER", "RIGHT".
Contents
LISTVIEW FUNCTIONS
ListView supports these functions in addition to the Shared View functions.
GetLabel(listviewname, labelname)
Makes the ListView.SingleLineLayout.Label accessible as a Label view.
The layout functions of the ListView items may be changed using the label functions.
SetFastScrollEnabled(listviewname, scrollstate)
Sets whether the fast scroll icon will appear when the user scrolls the list. The default Is False.
SetItemHeight(listviewname, itemheight)
Sets the ItemHeight of the SingleLineLayout in a ListView.
SetLayoutBackgroundColor(listviewname, cornerradius, backgroundcolor)
Set the ListView.SingleLineLayout.Background property of the ListView to a ColorDrawable.
SetLayoutBackgroundColorgradient(listviewname, orientation, cornerradius, colorsarrayname)
Set the ListView.SingleLineLayout.Background property of the ListView to a GradientDrawable.
Returns false if less than two colors are in the array or name not found otherwise returns true.
Orientation can be one of the following -
"TOP_BOTTOM", "TR_BL" (Top-Right To Bottom-Left, "RIGHT_LEFT", "BR_TL" (Bottom-Right To Top-Left)
"BOTTOM_TOP", "BL_TR" (Bottom-Left To Top-Right), "LEFT_RIGHT", "TL_BR" (Top-Left To Bottom-Right)
SetScrollColor(listviewname, color)
Sets the background color that will be used while scrolling the ListView.
Contents
LISTVIEW AND SPINNER FUNCTIONS
ListView and Spinner support these functions in addition to the Shared View functions.
Add(viewname, item)
Add an item To a ListView or Spinner.
AddAll(viewname, itemarrayname)
Add an array of items to a ListView or Spinner.
Clear(viewname)
Clears the items from a ListView or Spinner.
GetItem(viewname, index)
Returns the item at the specified index from a ListView or Spinner.
GetSize(viewname)
Returns the number of items in a ListView or Spinner.
RemoveAt(viewname, index)
Removes the item at the specified index from a ListView or Spinner.
Contents
PROGRESSBAR FUNCTIONS
ProgressBar supports these functions in addition to the Shared View functions.
GetIndeterminate(progressbarname)
Returns the current ProgressBar Indeterminate state, True or False.
GetProgress(progressbarname)
Returns the current ProgressBar Progress value between 0 and 100.
SetIndeterminate(progressbarname, indeterminate)
Sets the current ProgressBar Indeterminate stae, either True or False.
SetProgress(progressbarname, progress)
Sets the current ProgressBar Progress value. Should be between 0 and 100.
Contents
SCROLLVIEW FUNCTIONS
Scrollviews support these functions in addition to the Shared View functions.
Scrollview functions work on both Scrollviews and HorizontalScrollviews
FullScroll(scrollviewname, bottom)
Scrolls the ScrollView to the top or bottom.
True scrolls to the bottom, False scrolls to the top.
GetPanel(scrollviewname, panelname)
Makes the ScrollView Panel accessible as a named Panel View.
GetScrollPosition(scrollviewname)
Returns the current ScrollView ScrollPosition.
SetScrollPosition(scrollviewname, position)
Sets the current ScrollView ScrollPosition.
Contents
SEEKBAR FUNCTIONS
SeekBar supports these functions in addition to the Shared View functions.
GetMax(seekbarname)
Returns the current SeekBar Max value. The default is 100.
GetValue(seekbarname)
Returns the current SeekBar value. The minimum value is always zero.
SetMax(seekbarname, maxvalue)
Sets the current SeekBar Max value. The default is 100.
SetValue(seekbarname, value)
Sets the current SeekBar Value. Should be between 0 and Max.
Contents
SPINNER FUNCTIONS
Spinner supports these functions in addition to the Shared View functions.
SetSelectedIndex(spinnername)
Returns the index of the selected item of a Spinner. Returns -1 if no item is selected.
GetSelectedItem(spinnername)
Returns the the selected item of a Spinner. Returns "" if no item is selected.
SetPrompt(spinnername, prompt)
Sets the title that will be displayed when the Spinner is opened.
SetSelectedIndex(spinnername, index)
Selects the item at the specified index of a Spinner. Pass -1 if no item is selected.
Contents
TABHOST
TabHost supports these functions in addition to the Shared View functions.
AddTab(title, panelname, parenttabhostname)
Add a Tab and a new associated Panel to a TabHost.
The panelname may be used to add views To the Tab.
GetCurrentTab(tabhostname)
Returns the index of the current tab page.
GetTabCount(tabhostname)
Returns the number of tab pages.
SetCurrentTab(tabhostname, tabnumber)
Selects the current tab page.
Contents
TEXTVIEW FUNCTIONS
Views containing text support these functions in addition to the Shared View functions.
CreateTypeface(typeface, style)
There is one Typeface but it can be reinitialised as required.
Typeface - "Default", "Monospace", "Serif", "Sans_Serif"
Style - 0 Normal : 1 Bold : 2 Italic : 3 Bold_Italic
GetText(viewname)
Get the Text property, if any, of the named view.
SetGravity(viewname, gravity)
Set the Gravity property, if any, of the named view.
The Gravity properties below may be used, or use the following values.
NO_GRAVITY = 0; TOP = 48 (0x30) ; BOTTOM = 80 (0x50; LEFT = 3; RIGHT = 5; CENTER = 17 (0x11);
CENTER_HORIZONTAL = 1; CENTER_VERTICAL = 16 (0x10) ; FILL = 119 (0x77);
SetText(viewname, text)
Set the Text property, if any, of the named view.
SetTextColor(viewname, color)
Set the TextColor property, if any, of the named view.
SetTextSize(viewname, size)
Set the TextSize property, if any, of the named view.
SetTypeface(viewname)
Set the Typeface property, if any, of the named view to the current typeface.
Contents
TIMER FUNCTIONS
There is one timer and the Timer Tick events are vectored to "Sub timer_tick".
SetTimerEnabled(enabled)
Enable or disable the Timer.
SetTimerInterval(interval)
Set the timer interval in milliseconds.
These dialogs allow interaction with the user.
Contents
USER INTERACTION FUNCTIONS
CallDoEvents
Allow the message loop to run, lets views repaint themselves.
Dialog reponse codes
DialogResponse_Positive
DialogResponse_Cancel
DialogResponse_Negative
GetInput
Get the user input from the latest InputBox, InputDate or InputTime modal dialog.
Set the positive, cancel and negative parameters to the desired button text or leave blank to omit the button.
InputBox(prompt, title, positive, cancel, negative, inputtype)
Show a modal dialog box and prompt the user for data.
Inputtype sets the value of the InpuBox InputType property.
Returns a DialogResponse value with the input text available by calling GetInput.
InputBox InputType codes
Type_Decimal
Type_Numbers
Type_None
Type_Phone
Type_Text
InputCustom(viewname, title, positive, cancel, negative)
Allows a custom dialog to be presented to the user.
viewname - the name of a single view to display in the dialog, most probably a panel
title - the text in the dialog's title bar.
Returns a dialog response.
Example:
# first add your panel. It needs a black background
AddPanel("mypanel", 0, 0, pwidth, pheight, "")
SetColor("mypanel", 0, Color_Black)
# next, add all the desired views to the panel like this
AddLabel("mylabel", 0, 0, 60 * ScreenScale, 30 * ScreenScale, "mypanel")
SetText("mylabel", "label text")
# now remove the panel from the activity
RemoveFromParent("mypanel")
# now call InputCustom
sel = InputCustom("mypanel", "Yes", "Cancel", "No")
InputDate(prompt, title, startdateticks, positive, cancel, negative)
Show a modal dialog box and prompt the user for a date.
Returns a DialogResponse value with the input value avalable to GetInput as a ticks value.
InputFile(filepath, filename, filefilter, title, positive, cancel, negative)
Show a modal dialog box and prompt the user for a path or file name.
Returns a DialogResponse value with the input values available to GetInput as a comma separated string.
The first part is the file path and the last part is file name. If the user selected a path the file name is an empty string.
InputListBox(itemarrayname, title, selecteditem)
Show a modal dialog box and prompt the user to select an item.
selecteditem is the index of the item that will first be selected or -1 if no item should be preselected.
Returns the index of the selected item or DialogResponse.Cancel if the user pressed on the back key.
InputMultiListBox(itemarrayname, title)
Show a modal dialog box and prompt the user to select one or more items.
Returns a comma separated list of indices selected that may be separated with StrSplit.
Returns an empty string ("") if the Back button was pressed or no items were selected.
InputNumber(showsign, digits, number, title, positive, cancel, negative)
Show a modal dialog box and prompt the user for an integer number.
If ShowSign is True the sign of the number corresponds to the sign entered by the user.
Returns a DialogResponse value with the input number available to GetInput.
If ShowSign is True the sign of the number corresponds to the sign entered by the user.
InputTime(prompt, title, starttimeticks, as24hours, positive, cancel, negative)
Show a modal dialog box and prompt the user for a time.
Returns a DialogResponse value with the input value available to GetInput as a ticks value.
MessageBox(message, title, positive, cancel, negative)
Show a modal dialog box and prompt the user to make a selection.
Returns a DialogResponse.
ProgressHide
Hide a non-modal progress dialog.
ProgressShow(text, usercancel)
Show a non-modal progress dialog.
Shows a dialog with a circular spinning bar and the specified text.
Unlike Msgbox And InputList methods, the code will not block.
You should call ProgressDialogHide To remove the dialog.
If usercancel is True The dialog will also be removed If the user presses on the Back key.
ShowToast(message, longduration)
Shows a Toast. Setting longduration to true will cause the toast to stay on the screen longer.
Contents
COLOR CONSTANTS
These additional color constants return the color codes for the named color.
cDarkGray
cLightGray
cMagenta
cTransparent
Contents
KEYCODE FUNCTIONS AND CONSTANTS
Pass the KeyCode value from the Activity_KeyPress event to any of these functions
They will Return True or False depending upon whether the passed KeyCode is contained within that particular set.
Key_isNumber(KeyCode)
Numeric keys are: 0123456789
Key_isAlpha(KeyCode)
Alpha keys are: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Key_isSymbol(KeyCode)
Symbol keys are: '@/,=(-.+#^);\*
Key_isKeyboard(KeyCode)
Keyboard keys are: AltLeft AltRight Clear Del Enter Num ShiftLeft ShiftRight Space Symbol
Key_isDPad(KeyCode)
DPad Keys are: Left Center Right Up Down
Key_isMedia(KeyCode)
Media keys are: FastForward Next Play/Pause Rewind Stop Mute
Key_isDevice(KeyCode)
Device keys are : Back Call Camera EndCall Envelope Explorer Focus Grave HeadsetHook Home
Menu Notification Search SoftLeft SoftRight VolumeUp VolumeDown
Pass a KeyCode to these functions to get the ASCII value of a key as returned by Asc().
Whether a KeyCode is a letter, number or symbol can be checked using the KeyCode functions above.
KeyCodes for 0 to 9 are integer values 7 to 16.
KeyCodes for letters A to Z are integer values 29 to 54.
KeyToAsciiUpper(KeyCode)
KeyToAsciiLower(KeyCode)
KeyToNumberKey(KeyCode)
KeyCode constants:
Note that not all KeyCode constants are supported.
Whether a KeyCode is a letter, number or symbol can be checked using the KeyCode functions above.
KeyCodes for 0 to 9 are integer values 7 to 16.
KeyCodes for letters A to Z are integer values 29 to 54.
Key_AltLeft
Key_AltRight
Key_Back
Key_Call
Key_Camera
Key_Clear
Key_Del
Key_DPadCenter
Key_DPadDown
Key_DPadLeft
Key_DPadRight
Key_DPadUp
Key_EndCall
Key_Enter
Key_Envelope
Key_Explorer
Key_Focus
Key_Grave
Key_HeadSetHook
Key_Home
Key_MediaFastForward
Key_MediaNext
Key_MediaPlayPause
Key_MediaPrevious
Key_MediaRewind
Key_MediaStop
Key_Menu
Key_Mute
Key_Notification
Key_Num
Key_Search
Key_ShiftLeft
Key_ShiftRight
Key_SoftLeft
Key_SoftRight
Key_Sym
Key_Tab
Key_Unknown
Key_VolumeDown
Key_VolumnUp
Contents
GRAVITY CONSTANTS
These gravity constants return gravity values needed by functions for justifying text and images
They may be used instead of hard coding numeric values.
Gravity_None
Gravity_Top
Gravity_Bottom
Gravity_Left
Gravity_Right
Gravity_Center
Gravity_CenterHorizontal
(also Gravity_HCenter)
Gravity_CenterVertical
(also Gravity_VCenter)
Gravity_Fill
Contents
TYPEFACE CONSTANTS
These typeface constants return the values needed for the typeface functions.
They may be used instead of hard coding numeric values.
FontDefault
FontMonospace
FontSerif
FontSansSerif
StyleNormal
StyleBold
StyleItalic
StyleBoldItalic
Contents