Each activity module include a predefined Activity object. Activity is the main component of your application. Activities have three special life cycle related event: Activity_Create, Activity_Resume and Activity_Pause. See this tutorial for more information about activities and processes life cycle: Life cycle tutorial.
You can add and remove views to this activity with AddView and RemoveViewAt methods. You can also load a layout file with LoadLayout. The Touch event can be used to handle user touches. The first parameter of this event is the Action parameter. The parameter values can be ACTION_DOWN, ACTION_MOVE or ACTION_UP. Use this value to find the user current action. The KeyPress and KeyUp events occur when the user presses or releases a key, assuming that no other view has consumed this event (like EditText). When handling the KeyPress or KeyUp event you should return a boolean value which tells whether the event was consumed. For example if the user pressed on the Back key and you return True then the OS will not close your activity. SubActivity_KeyPress (KeyCodeAsInt) AsBoolean IfKeycode = KeyCodes.KEYCODE_BACKThen ReturnTrue Else ReturnFalse EndIf EndSub You can add menu items to the activity with AddMenuItem method. Note that this method should only be called inside Activity_Create event. Starting from Android 4.3 it is not possible to show a modal dialog inside the KeyPress or KeyUp events, with one exception which is in the case of the Back key. If you need to show a modal dialog for other keys then you should call a sub with CallSubDelayed and show the modal dialog in that sub.
Events:
Touch (Action As Int, X As Float, Y As Float) KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event KeyUp (KeyCode As Int) As Boolean WindowFocusChanged (Focused As Boolean) ActionBarHomeClick PermissionResult (Permission As String, Result As Boolean) Click LongClick
An enhanced version of EditText which shows the user a drop down list with all items matching the currently entered characters. Items matching are items starting with the current input or items that include a word that starts with the current input (words must be separated with spaces). Call SetItems with the list of possible items.
ItemClick event is raised when the user clicks on an item from the list. Example: SubProcess_Globals
A Button view. If you change the button's background you will usually want to use StateListDrawable which allows you to set the "default" drawable and the "pressed" drawable. Note that the Up and Down events are still implemented but should not be used as they will not work properly on all devices. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
A CheckBox view. Unlike RadioButtons each CheckBox can be checked independently. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
EditText view is a view that allows the user to write free text (similar to WinForms TextBox). The EditText has two modes; SingleLine and MultiLine. You can set it to be multiline by calling EditText1.SingleLine = False On most devices the soft keyboard will show automatically when the user presses on the EditText. You can change the InputType property and change the type of keyboard that appears. For example: EditText1.InputType = EditText1.INPUT_TYPE_NUMBERS will cause the numeric keyboard to appear when the user presses on the EditText. Note that it will also cause the EditText to only accept numbers.
The TextChanged event fires whenever the text changes and it includes the old and new strings. The EnterPressed event fires when the user presses on the enter key or action key (Done or Next). The FocusChanged event fires when the view is focused or loses focus. HasFocus parameter value will be set accordingly. Note that most views are not focusable. For example, pressing on a Button will not change the focus state of an EditText. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Events:
TextChanged (Old As String, New As String) EnterPressed FocusChanged (HasFocus As Boolean)
HorizontalScrollView is a view that contains other views and allows the user to horizontally scroll those views. The HorizontalScrollView is similar to ScrollView which scrolls vertically. See the ScrollView tutorial for more information. The HorizontalScrollView has an inner panel which actually contains the child views. You can add views by calling: HorizontalScrollView1.Panel.AddView(...) Note that it is not possible to nest scrolling views. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
A view that shows an image. You can assign a bitmap using the Bitmap property. The Gravity property changes the way the image appears. The two most relevant values are Gravity.FILL (which will cause the image to fill the entire view) and Gravity.CENTER (which will draw the image in the view's center). This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
ListView is a very useful view that can handle large and small lists. The ListView raises two events. ItemClick is raised when an item is clicked and ItemLongClick is raised when an item is clicked and held. See the ListView tutorial for more information. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Events:
ItemClick (Position As Int, Value As Object) ItemLongClick (Position As Int, Value As Object)
A Panel is a view that holds other child views. You can add child views programmatically or by loading a layout file. The Panel raises the Touch event. The first parameter of this event is the Action which is one of the Activity action constants. Return True from the Touch event sub to consume the event (otherwise other views behind the Panel will receive the event). This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Events:
Touch (Action As Int, X As Float, Y As Float) Click LongClick
A progress bar view. The Progress property sets the progress value which is between 0 to 100. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
A RadioButton view. Only one RadioButton in a group can be checked. When a different RadioButton is checked all others will automatically be unchecked. Grouping is done by adding RadioButtons to the same activity or panel. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
ScrollView is a view that contains other views and allows the user to vertically scroll those views. See the ScrollView tutorial for more information. The ScrollView has an inner panel which actually contains the child views. You can add views by calling: ScrollView1.Panel.AddView(...) Note that it is not possible to nest scrolling views. For example a multiline EditText cannot be located inside a ScrollView. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
A view that allows the user to set a value by dragging a slider. Similar to WinForms TrackBar. The ValueChanged event is raised whenever the value is changed. The UserChanged parameter can be used to distinguish between changes done by the user and changes done programmatically. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Events:
ValueChanged (Value As Int, UserChanged As Boolean)
A folded list that opens when the user clicks on it and allows the user to choose an item. Similar to WinForms ComboBox. The ItemClick event is raised each time a user presses on an item (even if it is the already selected item). This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
TabHost is a view that contains multiple tab pages. Each tab page contains other child views. See the TabHost tutorial for more information. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
A ToggleButton view. This view which is similar to a button has two modes: ON and OFF. When the user presses on it, it will change its mode. You can set the text with the TextOn and TextOff properties. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
View is a special type of object. You cannot create new View objects. However all other view types can be assigned to a view variable. This allows you to access the shared properties of all views. For example this code hides all views of an activity: Fori = 0ToActivity.NumberOfViews - 1 DimvAsView v = Activity.GetView(i)
v.Visible = False Next This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
The WebView view uses the internal WebKit engine to display Html pages. The page displayed can be an online page loaded with LoadUrl or a Html string loaded with LoadHtml. The PageFinished event is raised after the page loads. OverrideUrl is called before loading any Url. If this method returns True then the Url will not be loaded. You can use this event as a way to handle click events in your code. UserAndPasswordRequired event is raised when accessing a site that requires basic authentication. You should return an array of strings with the username as the first element and password as the second element. For example:ReturnArrayAsString("someuser", "password123") Returning Null will cancel the request. Sending incorrect credentials will cause this event to be raised again. This is an 'Activity Object', it cannot be declared under Sub Process_Globals.
Permissions:
android.permission.INTERNET
Events:
PageFinished (Url As String) OverrideUrl (Url As String) As Boolean UserAndPasswordRequired (Host As String, Realm As String) As String()